Skip to content

Commit

Permalink
add unit test to ascii_art #700
Browse files Browse the repository at this point in the history
  • Loading branch information
o2sh committed Aug 15, 2022
1 parent e348771 commit 8fe3e42
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/ui/ascii_art.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,14 @@ impl<'a> AsciiArt<'a> {
end,
}
}

pub fn width(&self) -> usize {
assert!(self.end >= self.start);
self.end - self.start
}
}

pub fn get_min_start_max_end(lines: &[&str]) -> (usize, usize) {
fn get_min_start_max_end(lines: &[&str]) -> (usize, usize) {
lines
.iter()
.map(|line| {
Expand Down Expand Up @@ -239,6 +240,18 @@ fn char_token(s: &str) -> ParseResult<Token> {
mod test {
use super::*;

#[test]
fn test_get_min_start_max_end() {
let lines = [
" xxx",
" xxx",
" oo",
" o",
" xx",
];
assert_eq!(get_min_start_max_end(&lines), (3, 29));
}

#[test]
fn space_parses() {
assert_eq!(space_token(" "), Some(("", Token::Space)));
Expand Down

0 comments on commit 8fe3e42

Please sign in to comment.