init v.1.0.0
All checks were successful
CI / Check / Test (push) Successful in 3m40s

Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
2026-08-06 20:11:22 +02:00
commit 15fdace324
38 changed files with 2883 additions and 0 deletions

View File

@@ -0,0 +1,75 @@
mod common;
use common::{
EDGE_ONLY, ROOMY, SNUG, TINY, advance, bottom_right, logo_sprite, scene_in, sprite_count,
};
#[test]
fn hitting_a_corner_bursts_sparkles_at_that_corner() {
let mut scene = scene_in(SNUG);
advance(&mut scene, SNUG, 1);
let corner = bottom_right(SNUG);
assert!(scene.sprites().any(|sprite| sprite.position() == corner));
assert!(sprite_count(&scene) > 1);
}
#[test]
fn hitting_a_single_edge_recolours_but_does_not_burst() {
let mut scene = scene_in(EDGE_ONLY);
let before = logo_sprite(&scene).color();
advance(&mut scene, EDGE_ONLY, 1);
assert_ne!(logo_sprite(&scene).color(), before);
assert_eq!(sprite_count(&scene), 1);
}
#[test]
fn sparkles_expire_so_the_scene_reaches_a_steady_size() {
let mut scene = scene_in(SNUG);
advance(&mut scene, SNUG, 64);
let steady = sprite_count(&scene);
advance(&mut scene, SNUG, 512);
assert_eq!(sprite_count(&scene), steady);
}
#[test]
fn the_sparkle_buffer_holds_the_worst_case_without_dropping_any() {
let mut scene = scene_in(SNUG);
advance(&mut scene, SNUG, 256);
assert_eq!(sprite_count(&scene), 12 * 9 + 1);
}
#[test]
fn bounds_shrinking_below_the_logo_neither_recolours_nor_bursts() {
let mut scene = scene_in(ROOMY);
let before = logo_sprite(&scene).color();
advance(&mut scene, TINY, 64);
assert_eq!(logo_sprite(&scene).color(), before);
assert_eq!(sprite_count(&scene), 1);
}
#[test]
fn the_logo_never_leaves_the_bounds() {
let mut scene = scene_in(ROOMY);
for _ in 0..2048 {
advance(&mut scene, ROOMY, 1);
let logo = logo_sprite(&scene);
let (position, size) = (logo.position(), logo.dimensions());
assert!(position.x() >= 0.0 && position.y() >= 0.0);
assert!(position.x() + size.width() as f32 <= ROOMY.width() as f32);
assert!(position.y() + size.height() as f32 <= ROOMY.height() as f32);
}
}