Skip to content

Commit 8fe3e42

Browse files
committed
add unit test to ascii_art #700
1 parent e348771 commit 8fe3e42

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/ui/ascii_art.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,14 @@ impl<'a> AsciiArt<'a> {
2929
end,
3030
}
3131
}
32+
3233
pub fn width(&self) -> usize {
3334
assert!(self.end >= self.start);
3435
self.end - self.start
3536
}
3637
}
3738

38-
pub fn get_min_start_max_end(lines: &[&str]) -> (usize, usize) {
39+
fn get_min_start_max_end(lines: &[&str]) -> (usize, usize) {
3940
lines
4041
.iter()
4142
.map(|line| {
@@ -239,6 +240,18 @@ fn char_token(s: &str) -> ParseResult<Token> {
239240
mod test {
240241
use super::*;
241242

243+
#[test]
244+
fn test_get_min_start_max_end() {
245+
let lines = [
246+
" xxx",
247+
" xxx",
248+
" oo",
249+
" o",
250+
" xx",
251+
];
252+
assert_eq!(get_min_start_max_end(&lines), (3, 29));
253+
}
254+
242255
#[test]
243256
fn space_parses() {
244257
assert_eq!(space_token(" "), Some(("", Token::Space)));

0 commit comments

Comments
 (0)