Skip to content

Commit

Permalink
Updated tests for tokenizer.
Browse files Browse the repository at this point in the history
  • Loading branch information
andymac-2 committed Oct 20, 2019
1 parent b5682bf commit c790d0c
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions src/ascii_art.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,37 +257,39 @@ mod test {

#[test]
fn truncate() {
let colors_shim = Vec::new();
assert_eq!(Tokens("").render(&colors_shim, 0, 0), "\u{1b}[1;37m\u{1b}[0m");
assert_eq!(
Tokens("").truncate(0, 0).collect::<Vec<_>>(),
Tokens("").collect::<Vec<_>>()
);

assert_eq!(
Tokens(" ").render(&colors_shim, 0, 0),
"\u{1b}[1;37m\u{1b}[0m"
Tokens(" ").truncate(0, 0).collect::<Vec<_>>(),
Tokens("").collect::<Vec<_>>()
);
assert_eq!(
Tokens(" ").render(&colors_shim, 0, 5),
"\u{1b}[1;37m \u{1b}[0m"
Tokens(" ").truncate(0, 5).collect::<Vec<_>>(),
Tokens(" ").collect::<Vec<_>>()
);
assert_eq!(
Tokens(" ").render(&colors_shim, 1, 5),
"\u{1b}[1;37m \u{1b}[0m"
Tokens(" ").truncate(1, 5).collect::<Vec<_>>(),
Tokens(" ").collect::<Vec<_>>()
);
assert_eq!(
Tokens(" ").render(&colors_shim, 3, 5),
"\u{1b}[1;37m \u{1b}[0m"
Tokens(" ").truncate(3, 5).collect::<Vec<_>>(),
Tokens(" ").collect::<Vec<_>>()
);
assert_eq!(
Tokens(" ").render(&colors_shim, 0, 4),
"\u{1b}[1;37m \u{1b}[0m"
Tokens(" ").truncate(0, 4).collect::<Vec<_>>(),
Tokens(" ").collect::<Vec<_>>()
);
assert_eq!(
Tokens(" ").render(&colors_shim, 0, 3),
"\u{1b}[1;37m \u{1b}[0m"
Tokens(" ").truncate(0, 3).collect::<Vec<_>>(),
Tokens(" ").collect::<Vec<_>>()
);

assert_eq!(
Tokens(" {1} {5} {9} a").render(&colors_shim, 4, 10),
"\u{1b}[1;37m\u{1b}[0m\u{1b}[1;37m\u{1b}[0m\u{1b}[1;37m \u{1b}[0m\u{1b}[1;37m a\u{1b}[0m "
Tokens(" {1} {5} {9} a").truncate(4, 10).collect::<Vec<_>>(),
Tokens("{1}{5} {9} a").collect::<Vec<_>>()
);
}
}

0 comments on commit c790d0c

Please sign in to comment.