summaryrefslogtreecommitdiffstats
path: root/src/grid/tests.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/grid/tests.rs')
-rw-r--r--src/grid/tests.rs79
1 files changed, 12 insertions, 67 deletions
diff --git a/src/grid/tests.rs b/src/grid/tests.rs
index 169cefa0..547fbcf9 100644
--- a/src/grid/tests.rs
+++ b/src/grid/tests.rs
@@ -17,78 +17,23 @@
use super::{Grid, BidirectionalIterator};
use index::{Point, Line, Column};
-#[test]
-fn grid_swap_lines_ok() {
- let mut grid = Grid::new(Line(10), Column(1), &0);
- info!("");
-
- // swap test ends
- grid[Line(0)][Column(0)] = 1;
- grid[Line(9)][Column(0)] = 2;
-
- assert_eq!(grid[Line(0)][Column(0)], 1);
- assert_eq!(grid[Line(9)][Column(0)], 2);
-
- grid.swap_lines(Line(0), Line(9));
-
- assert_eq!(grid[Line(0)][Column(0)], 2);
- assert_eq!(grid[Line(9)][Column(0)], 1);
-
- // swap test mid
- grid[Line(4)][Column(0)] = 1;
- grid[Line(5)][Column(0)] = 2;
-
- info!("grid: {:?}", grid);
-
- assert_eq!(grid[Line(4)][Column(0)], 1);
- assert_eq!(grid[Line(5)][Column(0)], 2);
-
- grid.swap_lines(Line(4), Line(5));
-
- info!("grid: {:?}", grid);
-
- assert_eq!(grid[Line(4)][Column(0)], 2);
- assert_eq!(grid[Line(5)][Column(0)], 1);
-}
-
-#[test]
-#[should_panic]
-fn grid_swap_lines_oob1() {
- let mut grid = Grid::new(Line(10), Column(1), &0);
- grid.swap_lines(Line(0), Line(10));
-}
-
-#[test]
-#[should_panic]
-fn grid_swap_lines_oob2() {
- let mut grid = Grid::new(Line(10), Column(1), &0);
- grid.swap_lines(Line(10), Line(0));
-}
-
-#[test]
-#[should_panic]
-fn grid_swap_lines_oob3() {
- let mut grid = Grid::new(Line(10), Column(1), &0);
- grid.swap_lines(Line(10), Line(10));
-}
-
// Scroll up moves lines upwards
#[test]
fn scroll_up() {
info!("");
- let mut grid = Grid::new(Line(10), Column(1), &0);
+ let mut grid = Grid::new(Line(10), Column(1), 0, 0);
for i in 0..10 {
grid[Line(i)][Column(0)] = i;
}
info!("grid: {:?}", grid);
- grid.scroll_up(Line(0)..Line(10), Line(2));
+ grid.scroll_up(&(Line(0)..Line(10)), Line(2));
info!("grid: {:?}", grid);
- let mut other = Grid::new(Line(10), Column(1), &9);
+ let mut other = Grid::new(Line(10), Column(1), 0, 9);
other[Line(0)][Column(0)] = 2;
other[Line(1)][Column(0)] = 3;
@@ -111,18 +56,18 @@ fn scroll_up() {
fn scroll_down() {
info!("");
- let mut grid = Grid::new(Line(10), Column(1), &0);
+ let mut grid = Grid::new(Line(10), Column(1), 0, 0);
for i in 0..10 {
grid[Line(i)][Column(0)] = i;
}
info!("grid: {:?}", grid);
- grid.scroll_down(Line(0)..Line(10), Line(2));
+ grid.scroll_down(&(Line(0)..Line(10)), Line(2));
info!("grid: {:?}", grid);
- let mut other = Grid::new(Line(10), Column(1), &9);
+ let mut other = Grid::new(Line(10), Column(1), 0, 9);
other[Line(0)][Column(0)] = 8;
other[Line(1)][Column(0)] = 9;
@@ -145,7 +90,7 @@ fn scroll_down() {
fn test_iter() {
info!("");
- let mut grid = Grid::new(Line(5), Column(5), &0);
+ let mut grid = Grid::new(Line(5), Column(5), 0, 0);
for i in 0..5 {
for j in 0..5 {
grid[Line(i)][Column(j)] = i*5 + j;
@@ -155,14 +100,14 @@ fn test_iter() {
info!("grid: {:?}", grid);
let mut iter = grid.iter_from(Point {
- line: Line(0),
+ line: 4,
col: Column(0),
});
assert_eq!(None, iter.prev());
assert_eq!(Some(&1), iter.next());
assert_eq!(Column(1), iter.cur.col);
- assert_eq!(Line(0), iter.cur.line);
+ assert_eq!(4, iter.cur.line);
assert_eq!(Some(&2), iter.next());
assert_eq!(Some(&3), iter.next());
@@ -171,16 +116,16 @@ fn test_iter() {
// test linewrapping
assert_eq!(Some(&5), iter.next());
assert_eq!(Column(0), iter.cur.col);
- assert_eq!(Line(1), iter.cur.line);
+ assert_eq!(3, iter.cur.line);
assert_eq!(Some(&4), iter.prev());
assert_eq!(Column(4), iter.cur.col);
- assert_eq!(Line(0), iter.cur.line);
+ assert_eq!(4, iter.cur.line);
// test that iter ends at end of grid
let mut final_iter = grid.iter_from(Point {
- line: Line(4),
+ line: 0,
col: Column(4),
});
assert_eq!(None, final_iter.next());