diff --git a/tests/deser.rs b/tests/deser.rs index 19e5fda..d6f681c 100644 --- a/tests/deser.rs +++ b/tests/deser.rs @@ -124,60 +124,6 @@ impl Person { } } -#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] -struct RonConfig { - primitives: Primitives, - #[serde(default, skip_serializing_if = "Option::is_none")] - missing: Option, - enums: RonEnums, - people: Vec, -} - -impl RonConfig { - #[allow(dead_code)] - fn get() -> RonConfig { - RonConfig { - primitives: Primitives::get(), - missing: None, - enums: RonEnums::get(), - people: Person::get(), - } - } -} - -#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)] -struct RonEnums { - color: Color, - msg: RonMessage, -} - -impl RonEnums { - #[allow(dead_code)] - fn get() -> RonEnums { - RonEnums { - color: Color::Green, - msg: RonMessage::Response { - id: 60069, - value: String::from("Foobar"), - }, - } - } -} - -#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)] -// Ron doesn't support internally tagged enums -enum RonMessage { - Request { - id: u32, - resource: String, - operation: String, - }, - Response { - id: u32, - value: String, - }, -} - #[test] fn load_unknown() { let file = Builder::new().suffix(".unk").tempfile().unwrap(); diff --git a/tests/formats/ron.rs b/tests/formats/ron.rs index 55ba6cb..e0bd708 100644 --- a/tests/formats/ron.rs +++ b/tests/formats/ron.rs @@ -1,5 +1,5 @@ #![cfg(feature = "ron")] -use crate::RonConfig; +use crate::Config; use cfgfifo::*; use indoc::indoc; use pretty_assertions::assert_eq; @@ -30,7 +30,8 @@ static RON: &str = indoc! {r#" ), enums: ( color: green, - msg: Response( + msg: ( + type: "Response", id: 60069, value: "Foobar", ), @@ -56,13 +57,13 @@ static RON: &str = indoc! {r#" #[test] fn load_from_str() { - let r = Format::Ron.load_from_str::(RON); - assert_eq!(r.unwrap(), RonConfig::get()); + let r = Format::Ron.load_from_str::(RON); + assert_eq!(r.unwrap(), Config::get()); } #[test] fn dump_to_string() { - let r = Format::Ron.dump_to_string(&RonConfig::get()); + let r = Format::Ron.dump_to_string(&Config::get()); assert_eq!(r.unwrap(), RON); } @@ -72,14 +73,14 @@ fn load_from_reader() { writeln!(file, "{RON}").unwrap(); file.flush().unwrap(); file.rewind().unwrap(); - let r = Format::Ron.load_from_reader::<_, RonConfig>(file); - assert_eq!(r.unwrap(), RonConfig::get()); + let r = Format::Ron.load_from_reader::<_, Config>(file); + assert_eq!(r.unwrap(), Config::get()); } #[test] fn dump_to_writer() { let mut file = tempfile().unwrap(); - let r = Format::Ron.dump_to_writer(&file, &RonConfig::get()); + let r = Format::Ron.dump_to_writer(&file, &Config::get()); assert!(r.is_ok()); file.flush().unwrap(); file.rewind().unwrap(); @@ -94,14 +95,14 @@ fn load_from_file() { writeln!(file, "{RON}").unwrap(); file.flush().unwrap(); file.rewind().unwrap(); - let r = load::(file); - assert_eq!(r.unwrap(), RonConfig::get()); + let r = load::(file); + assert_eq!(r.unwrap(), Config::get()); } #[test] fn dump_to_file() { let mut file = Builder::new().suffix(".ron").tempfile().unwrap(); - let r = dump(&file, &RonConfig::get()); + let r = dump(&file, &Config::get()); assert!(r.is_ok()); file.flush().unwrap(); file.rewind().unwrap();