//! Tests for the row arithmetic that pins the inline viewport to the //! bottom of the screen: where its top belongs, and how much of the //! screen above has to scroll to get there without overwriting anything. use super::{Move, clear_from, next_top, pinned_top, scroll_up_needed}; #[test] fn a_viewport_shorter_than_the_screen_sits_flush_with_the_last_row() { assert_eq!(pinned_top(24, 4), 20); } #[test] fn a_viewport_as_tall_as_the_screen_starts_at_row_zero() { assert_eq!(pinned_top(24, 24), 0); } #[test] fn a_viewport_taller_than_the_screen_clamps_to_row_zero() { assert_eq!(pinned_top(10, 24), 0); } #[test] fn a_viewport_that_grows_moves_its_top_up_to_the_pinned_row() { assert_eq!(next_top(24, 6, 20), 18); } #[test] fn a_viewport_that_shrinks_keeps_its_top_where_it_is() { assert_eq!(next_top(24, 4, 18), 18); } #[test] fn a_viewport_that_keeps_its_height_keeps_its_top() { assert_eq!(next_top(24, 4, 20), 20); } #[test] fn room_below_the_current_row_needs_no_scroll() { assert_eq!(scroll_up_needed(5, 20), 0); } #[test] fn a_pinned_top_exactly_at_the_current_row_needs_no_scroll() { assert_eq!(scroll_up_needed(10, 10), 0); } #[test] fn a_pinned_top_above_the_current_row_scrolls_the_difference() { assert_eq!(scroll_up_needed(15, 5), 10); } #[test] fn a_viewport_that_moves_down_clears_from_the_row_it_came_from() { assert_eq!(clear_from(15, 25), 15); } #[test] fn a_viewport_that_moves_up_clears_from_the_row_it_lands_on() { assert_eq!(clear_from(15, 5), 5); } #[test] fn a_resize_that_grows_scrolls_the_screen_and_clears_from_the_row_it_lands_on() { assert_eq!( Move::resize(24, 6, 20), Move { scroll: 2, clear: 18, top: 18, rows: 6 } ); } #[test] fn a_resize_that_shrinks_keeps_its_top_and_clears_the_rows_below_it() { assert_eq!( Move::resize(24, 4, 18), Move { scroll: 0, clear: 18, top: 18, rows: 4 } ); } #[test] fn a_repin_that_moves_down_clears_from_the_row_it_came_from() { assert_eq!( Move::repin(24, 4, 18), Move { scroll: 0, clear: 18, top: 20, rows: 4 } ); } #[test] fn a_repin_that_moves_up_scrolls_the_screen_by_as_much_as_the_top_moves() { assert_eq!( Move::repin(24, 8, 20), Move { scroll: 4, clear: 16, top: 16, rows: 8 } ); }