Skip to content

Commit 12def53

Browse files
committed
tests for path and struct display impls
1 parent ab1260c commit 12def53

File tree

1 file changed

+24
-7
lines changed

1 file changed

+24
-7
lines changed

tests/happy.rs

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
use displaydoc::Display;
2-
// use std::path::PathBuf;
2+
3+
#[cfg(feature = "std")]
4+
use std::path::PathBuf;
5+
6+
#[derive(Display)]
7+
/// Just a basic struct {thing}
8+
struct HappyStruct {
9+
thing: &'static str,
10+
}
311

412
#[derive(Display)]
513
enum Happy {
@@ -18,8 +26,10 @@ enum Happy {
1826
/// Variant5 just has {0} many problems
1927
/// but multi line comments aren't one of them
2028
Variant5(u32),
21-
// /// The path {0.display()}
22-
// Variant6(PathBuf),
29+
30+
/// The path {0}
31+
#[cfg(feature = "std")]
32+
Variant6(PathBuf),
2333
}
2434

2535
fn assert_display<T: std::fmt::Display>(input: T, expected: &'static str) {
@@ -37,8 +47,15 @@ fn does_it_print() {
3747
"Variant4 wants to have a lot of lines\n\n Lets see how this works out for it",
3848
);
3949
assert_display(Happy::Variant5(2), "Variant5 just has 2 many problems");
40-
// assert_display(
41-
// Happy::Variant6(PathBuf::from("/var/log/happy")),
42-
// "The path /var/log/happy",
43-
// );
50+
51+
assert_display(HappyStruct { thing: "hi" }, "Just a basic struct hi");
52+
}
53+
54+
#[test]
55+
#[cfg(feature = "std")]
56+
fn does_it_print_path() {
57+
assert_display(
58+
Happy::Variant6(PathBuf::from("/var/log/happy")),
59+
"The path /var/log/happy",
60+
);
4461
}

0 commit comments

Comments
 (0)