Skip to content

Commit

Permalink
test: Show current glyph behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
epage committed Jul 9, 2024
1 parent 948af29 commit 913d8d6
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,63 @@ foo
"#]]
);
}

#[test]
fn render_custom_glyphs() {
let root = GlyphPalette {
middle_item: "[mid ]",
last_item: "[last ]",
item_indent: "[indent ]",

middle_skip: "[mskip]",
last_skip: "[lskip]",
skip_indent: "[iskip ]",
};
let middle = GlyphPalette {
middle_item: "(mid )",
last_item: "(last )",
item_indent: "(indent )",

middle_skip: "(mskip)",
last_skip: "(lskip)",
skip_indent: "(iskip )",
};

let tree = Tree::new("node 1").with_glyphs(root).with_leaves([
Tree::new("node 1.1"),
Tree::new("node 1.2"),
Tree::new("node 1.3").with_leaves([
Tree::new("node 1.3.1").with_glyphs(middle),
Tree::new("node 1.3.2").with_glyphs(middle),
Tree::new("node 1.3.3")
.with_glyphs(middle)
.with_leaves(["node 1.3.3.1", "node 1.3.3.2"]),
]),
Tree::new("node 1.4").with_leaves([
Tree::new("node 1.4.1"),
Tree::new("node 1.4.2"),
Tree::new("node 1.4.3").with_leaves(["node 1.4.3.1", "node 1.4.3.2"]),
]),
]);
assert_data_eq!(
format!("{}", tree),
str![[r#"
node 1
├── node 1.1
├── node 1.2
├── node 1.3
[mskip][iskip ](mid )(indent )node 1.3.1
[mskip][iskip ](mid )(indent )node 1.3.2
[mskip][iskip ](last )(indent )node 1.3.3
[mskip][iskip ][lskip][iskip ]├── node 1.3.3.1
[mskip][iskip ][lskip][iskip ]└── node 1.3.3.2
└── node 1.4
[lskip][iskip ]├── node 1.4.1
[lskip][iskip ]├── node 1.4.2
[lskip][iskip ]└── node 1.4.3
[lskip][iskip ][lskip][iskip ]├── node 1.4.3.1
[lskip][iskip ][lskip][iskip ]└── node 1.4.3.2
"#]]
);
}

0 comments on commit 913d8d6

Please sign in to comment.