From cbb9ef88ea6f6452614dd8bbffce7203b1358a55 Mon Sep 17 00:00:00 2001 From: Ryan Leckey Date: Mon, 2 Jul 2018 15:33:38 -0700 Subject: Run rustfmt (nightly) --- tests/file_ini.rs | 123 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 63 insertions(+), 60 deletions(-) (limited to 'tests/file_ini.rs') diff --git a/tests/file_ini.rs b/tests/file_ini.rs index 4c0030a..30d86a3 100644 --- a/tests/file_ini.rs +++ b/tests/file_ini.rs @@ -1,60 +1,63 @@ -extern crate config; -extern crate serde; -extern crate float_cmp; - -#[macro_use] -extern crate serde_derive; - -use config::*; - -#[derive(Debug, Deserialize, PartialEq)] -struct Place { - name: String, - longitude: f64, - latitude: f64, - favorite: bool, - reviews: u64, - rating: Option, -} - -#[derive(Debug, Deserialize, PartialEq)] -struct Settings { - debug: f64, - place: Place, -} - -fn make() -> Config { - let mut c = Config::default(); - c.merge(File::new("tests/Settings", FileFormat::Ini)) - .unwrap(); - c -} - -#[test] -fn test_file() { - let c = make(); - let s: Settings = c.try_into().unwrap(); - assert_eq!(s, Settings { - debug: 1.0, - place: Place { - name: String::from("Torre di Pisa"), - longitude: 43.7224985, - latitude: 10.3970522, - favorite: false, - reviews: 3866, - rating: Some(4.5), - }, - }); -} - -#[test] -fn test_error_parse() { - let mut c = Config::default(); - let res = c.merge(File::new("tests/Settings-invalid", FileFormat::Ini)); - - assert!(res.is_err()); - assert_eq!( - res.unwrap_err().to_string(), - r#"2:0 Expecting "[Some('='), Some(':')]" but found EOF. in tests/Settings-invalid.ini"# - ); -} +extern crate config; +extern crate float_cmp; +extern crate serde; + +#[macro_use] +extern crate serde_derive; + +use config::*; + +#[derive(Debug, Deserialize, PartialEq)] +struct Place { + name: String, + longitude: f64, + latitude: f64, + favorite: bool, + reviews: u64, + rating: Option, +} + +#[derive(Debug, Deserialize, PartialEq)] +struct Settings { + debug: f64, + place: Place, +} + +fn make() -> Config { + let mut c = Config::default(); + c.merge(File::new("tests/Settings", FileFormat::Ini)) + .unwrap(); + c +} + +#[test] +fn test_file() { + let c = make(); + let s: Settings = c.try_into().unwrap(); + assert_eq!( + s, + Settings { + debug: 1.0, + place: Place { + name: String::from("Torre di Pisa"), + longitude: 43.7224985, + latitude: 10.3970522, + favorite: false, + reviews: 3866, + rating: Some(4.5), + }, + } + ); +} + +#[test] +fn test_error_parse() { + let mut c = Config::default(); + let res = c.merge(File::new("tests/Settings-invalid", FileFormat::Ini)); + + assert!(res.is_err()); + assert_eq!( + res.unwrap_err().to_string(), + r#"2:0 Expecting "[Some('='), Some(':')]" but found EOF. in tests/Settings-invalid.ini"# + ); +} -- cgit v1.2.3