mod common; use common::{LOGO, ROOMY, scene_in, size, sprite_count, try_scene}; use domain::{Dimensions, Point2D, Vector2D}; #[test] fn dimensions_reject_zero_extents() { assert!(Dimensions::new(0, 10).is_none()); assert!(Dimensions::new(10, 0).is_none()); assert!(Dimensions::new(10, 10).is_some()); } #[test] fn points_reject_non_finite_coordinates() { assert!(Point2D::new(f32::NAN, 0.0).is_none()); assert!(Point2D::new(0.0, f32::INFINITY).is_none()); assert!(Point2D::new(-1.0, 1.0).is_some()); } #[test] fn vectors_reject_non_finite_components() { assert!(Vector2D::new(f32::NAN, 1.0).is_none()); assert!(Vector2D::new(1.0, f32::NEG_INFINITY).is_none()); assert!(Vector2D::new(0.0, 0.0).is_some()); } #[test] fn the_logo_must_fit_inside_the_bounds() { assert!(try_scene(LOGO, LOGO).is_ok()); assert!(try_scene(size(LOGO.width() + 1, LOGO.height()), LOGO).is_err()); assert!(try_scene(size(LOGO.width(), LOGO.height() + 1), LOGO).is_err()); } #[test] fn a_new_scene_holds_only_the_logo() { assert_eq!(sprite_count(&scene_in(ROOMY)), 1); }