Skip to content

Commit 948af29

Browse files
committed
test: Port to snapbox
1 parent fee7d05 commit 948af29

File tree

3 files changed

+203
-10
lines changed

3 files changed

+203
-10
lines changed

Cargo.lock

Lines changed: 177 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ pre-release-replacements = [
116116
[dependencies]
117117

118118
[dev-dependencies]
119+
snapbox = "0.6.10"
119120

120121
[lints]
121122
workspace = true

src/tests.rs

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,45 @@
1+
use snapbox::assert_data_eq;
2+
use snapbox::str;
3+
14
use super::*;
25

36
#[test]
47
fn render_tree_root() {
58
let tree = Tree::new("foo");
6-
assert_eq!(format!("{}", tree), "foo\n");
9+
assert_data_eq!(
10+
format!("{}", tree),
11+
str![[r#"
12+
foo
13+
14+
"#]]
15+
);
716
}
817

918
#[test]
1019
fn render_tree_with_leaves() {
1120
let tree = Tree::new("foo").with_leaves([Tree::new("bar").with_leaves(["baz"])]);
12-
assert_eq!(
21+
assert_data_eq!(
1322
format!("{}", tree),
14-
r#"foo
23+
str![[r#"
24+
foo
1525
└── bar
1626
└── baz
17-
"#
27+
28+
"#]]
1829
);
1930
}
2031

2132
#[test]
2233
fn render_tree_with_multiple_leaves() {
2334
let tree = Tree::new("foo").with_leaves(["bar", "baz"]);
24-
assert_eq!(
35+
assert_data_eq!(
2536
format!("{}", tree),
26-
r#"foo
37+
str![[r#"
38+
foo
2739
├── bar
2840
└── baz
29-
"#
41+
42+
"#]]
3043
);
3144
}
3245

@@ -36,13 +49,15 @@ fn render_tree_with_multiline_leaf() {
3649
Tree::new("hello\nworld").with_multiline(true),
3750
Tree::new("goodbye\nworld").with_multiline(true),
3851
]);
39-
assert_eq!(
52+
assert_data_eq!(
4053
format!("{}", tree),
41-
r#"foo
54+
str![[r#"
55+
foo
4256
├── hello
4357
│ world
4458
└── goodbye
4559
world
46-
"#
60+
61+
"#]]
4762
);
4863
}

0 commit comments

Comments
 (0)