1 | #![allow (clippy::wildcard_imports)] |
2 | |
3 | use serde::Deserialize; |
4 | |
5 | #[derive(Debug, Deserialize, PartialEq)] |
6 | struct Struct { |
7 | value: Enum, |
8 | } |
9 | |
10 | #[derive(Debug, Deserialize, PartialEq)] |
11 | enum Enum { |
12 | Variant, |
13 | } |
14 | |
15 | #[test] |
16 | fn unknown_variant() { |
17 | let error = basic_toml::from_str::<Struct>("value = \"NonExistent \"" ).unwrap_err(); |
18 | |
19 | assert_eq!( |
20 | error.to_string(), |
21 | "unknown variant `NonExistent`, expected `Variant` for key `value` at line 1 column 1" |
22 | ); |
23 | } |
24 | |
25 | #[test] |
26 | fn from_str() { |
27 | let s = basic_toml::from_str::<Struct>("value = \"Variant \"" ).unwrap(); |
28 | |
29 | assert_eq!(Enum::Variant, s.value); |
30 | } |
31 | |