1// We need to test [ui_macros::DerivePathStr] here as we can't invoke it
2// in the `ui_macros` crate.
3#[cfg(test)]
4mod tests {
5 use strum::EnumString;
6 use ui_macros::{DerivePathStr, path_str};
7
8 #[test]
9 fn test_derive_path_str_with_prefix() {
10 #[derive(Debug, EnumString, DerivePathStr)]
11 #[strum(serialize_all = "snake_case")]
12 #[path_str(prefix = "test_prefix")]
13 enum SomeAsset {
14 FooBar,
15 Baz,
16 }
17
18 assert_eq!(SomeAsset::FooBar.path(), "test_prefix/foo_bar");
19 assert_eq!(SomeAsset::Baz.path(), "test_prefix/baz");
20 }
21
22 #[test]
23 fn test_derive_path_str_with_prefix_and_suffix() {
24 #[derive(Debug, EnumString, DerivePathStr)]
25 #[strum(serialize_all = "snake_case")]
26 #[path_str(prefix = "test_prefix", suffix = ".svg")]
27 enum SomeAsset {
28 FooBar,
29 Baz,
30 }
31
32 assert_eq!(SomeAsset::FooBar.path(), "test_prefix/foo_bar.svg");
33 assert_eq!(SomeAsset::Baz.path(), "test_prefix/baz.svg");
34 }
35}