diff options
author | Joe Wilm <joe@jwilm.com> | 2018-03-09 13:49:47 -0800 |
---|---|---|
committer | Joe Wilm <joe@jwilm.com> | 2018-04-02 08:27:29 -0700 |
commit | bc3b721a531daec77a4afdc70211ea3df0346aad (patch) | |
tree | 3f14d4d206afe71e3cf1cf8e81c3becb71e000fb /src/grid/tests.rs | |
parent | 9ee1cf2455d5512b087757e09451f9d122548da2 (diff) | |
download | alacritty-bc3b721a531daec77a4afdc70211ea3df0346aad.tar.gz alacritty-bc3b721a531daec77a4afdc70211ea3df0346aad.zip |
Make tests compile again
Some tests are still not passing, though.
A migration script was added to migrate serialized grids from
pre-scrollback to the current format. The script is included with this
commit for completeness, posterity, and as an example to be used in the
future.
A few tests in grid/tests.rs were removed due to becoming irrelevant.
Diffstat (limited to 'src/grid/tests.rs')
-rw-r--r-- | src/grid/tests.rs | 79 |
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()); |