diff --git a/tests/Settings.toml b/tests/Settings.toml index 26e6d265..f7ec124e 100644 --- a/tests/Settings.toml +++ b/tests/Settings.toml @@ -9,6 +9,7 @@ code = 53 boolean_s_parse = "fals" arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] +quarks = ["up", "down", "strange", "charm", "bottom", "top"] [diodes] green = "off" @@ -40,3 +41,7 @@ rating = 4.5 [place.creator] name = "John Smith" + +[proton] +up = 2 +down = 1 diff --git a/tests/get.rs b/tests/get.rs index 7e3be8a6..0fbdbcff 100644 --- a/tests/get.rs +++ b/tests/get.rs @@ -9,7 +9,7 @@ extern crate serde_derive; use config::*; use float_cmp::ApproxEqUlps; -use std::collections::HashMap; +use std::collections::{HashMap, HashSet}; #[derive(Debug, Deserialize)] struct Place { @@ -225,3 +225,29 @@ fn test_enum() { assert_eq!(s.diodes["blue"], Diode::Blinking(300, 700)); assert_eq!(s.diodes["white"], Diode::Pattern{name: "christmas".into(), inifinite: true,}); } + +#[test] +fn test_enum_key() { + #[derive(Debug, Deserialize, PartialEq, Eq, Hash)] + enum Quark { + Up, + Down, + Strange, + Charm, + Bottom, + Top, + } + + #[derive(Debug, Deserialize)] + struct Settings { + proton: HashMap, + // Just to make sure that set keys work too. + quarks: HashSet, + } + + let c = make(); + let s: Settings = c.try_into().unwrap(); + + assert_eq!(s.proton[&Quark::Up], 2); + assert_eq!(s.quarks.len(), 6); +}