1#[cfg(test)]
2mod tests {
3 use strum::EnumString;
4 use ui_macros::{path_str, DerivePathStr};
5
6 #[test]
7 fn test_derive_path_str_with_prefix() {
8 #[derive(Debug, EnumString, DerivePathStr)]
9 #[strum(serialize_all = "snake_case")]
10 #[path_str(prefix = "test_prefix")]
11 enum MyEnum {
12 FooBar,
13 Baz,
14 }
15
16 assert_eq!(MyEnum::FooBar.path(), "test_prefix/foo_bar");
17 assert_eq!(MyEnum::Baz.path(), "test_prefix/baz");
18 }
19
20 #[test]
21 fn test_derive_path_str_with_prefix_and_suffix() {
22 #[derive(Debug, EnumString, DerivePathStr)]
23 #[strum(serialize_all = "snake_case")]
24 #[path_str(prefix = "test_prefix", suffix = ".txt")]
25 enum MyEnum {
26 FooBar,
27 Baz,
28 }
29
30 assert_eq!(MyEnum::FooBar.path(), "test_prefix/foo_bar.txt");
31 assert_eq!(MyEnum::Baz.path(), "test_prefix/baz.txt");
32 }
33}