summaryrefslogtreecommitdiff
path: root/alacritty_terminal/src/grid/tests.rs
diff options
context:
space:
mode:
Diffstat (limited to 'alacritty_terminal/src/grid/tests.rs')
-rw-r--r--alacritty_terminal/src/grid/tests.rs34
1 files changed, 34 insertions, 0 deletions
diff --git a/alacritty_terminal/src/grid/tests.rs b/alacritty_terminal/src/grid/tests.rs
index e4fdad5c..e8f4fb8d 100644
--- a/alacritty_terminal/src/grid/tests.rs
+++ b/alacritty_terminal/src/grid/tests.rs
@@ -37,6 +37,40 @@ impl GridCell for usize {
}
}
+#[test]
+fn grid_clamp_buffer_point() {
+ let mut grid = Grid::new(Line(10), Column(10), 1_000, 0);
+ grid.display_offset = 5;
+
+ let point = grid.clamp_buffer_to_visible(Point::new(10, Column(3)));
+ assert_eq!(point, Point::new(Line(4), Column(3)));
+
+ let point = grid.clamp_buffer_to_visible(Point::new(15, Column(3)));
+ assert_eq!(point, Point::new(Line(0), Column(0)));
+
+ let point = grid.clamp_buffer_to_visible(Point::new(4, Column(3)));
+ assert_eq!(point, Point::new(Line(9), Column(9)));
+
+ grid.display_offset = 0;
+
+ let point = grid.clamp_buffer_to_visible(Point::new(4, Column(3)));
+ assert_eq!(point, Point::new(Line(5), Column(3)));
+}
+
+#[test]
+fn visible_to_buffer() {
+ let mut grid = Grid::new(Line(10), Column(10), 1_000, 0);
+ grid.display_offset = 5;
+
+ let point = grid.visible_to_buffer(Point::new(Line(4), Column(3)));
+ assert_eq!(point, Point::new(10, Column(3)));
+
+ grid.display_offset = 0;
+
+ let point = grid.visible_to_buffer(Point::new(Line(5), Column(3)));
+ assert_eq!(point, Point::new(4, Column(3)));
+}
+
// Scroll up moves lines upwards
#[test]
fn scroll_up() {