diff options
author | rdkt13 <rdkt13@gmail.com> | 2020-09-06 11:23:18 +0200 |
---|---|---|
committer | rdkt13 <rdkt13@gmail.com> | 2020-09-06 11:23:18 +0200 |
commit | 53b8bf74381dc292834a356e4a760755d64fc60e (patch) | |
tree | 273b2b7f3fa84df5d2d85850f8f580740ce9a50a | |
parent | 05f6d42512ed3adcb64da26d33fee7643ea5ed1b (diff) |
Fix paths in tests expectations for all platforms
-rw-r--r-- | tests/errors.rs | 11 | ||||
-rw-r--r-- | tests/file_hjson.rs | 5 | ||||
-rw-r--r-- | tests/file_ini.rs | 5 | ||||
-rw-r--r-- | tests/file_json.rs | 5 | ||||
-rw-r--r-- | tests/file_toml.rs | 5 | ||||
-rw-r--r-- | tests/file_yaml.rs | 8 |
6 files changed, 28 insertions, 11 deletions
diff --git a/tests/errors.rs b/tests/errors.rs index 5f4a1a5..159473e 100644 --- a/tests/errors.rs +++ b/tests/errors.rs @@ -6,6 +6,7 @@ extern crate config; extern crate serde_derive; use config::*; +use std::path::PathBuf; fn make() -> Config { let mut c = Config::default(); @@ -20,10 +21,12 @@ fn test_error_parse() { let mut c = Config::default(); let res = c.merge(File::new("tests/Settings-invalid", FileFormat::Toml)); + let path : PathBuf = ["tests", "Settings-invalid.toml"].iter().collect(); + assert!(res.is_err()); assert_eq!( res.unwrap_err().to_string(), - "failed to parse datetime for key `error` at line 2 column 9 in tests/Settings-invalid.toml".to_string() + format!("failed to parse datetime for key `error` at line 2 column 9 in {}", path.to_str().unwrap()) ); } @@ -33,12 +36,12 @@ fn test_error_type() { let res = c.get::<bool>("boolean_s_parse"); + let path : PathBuf = ["tests", "Settings.toml"].iter().collect(); + assert!(res.is_err()); assert_eq!( res.unwrap_err().to_string(), - "invalid type: string \"fals\", expected a boolean for key \ - `boolean_s_parse` in tests/Settings.toml" - .to_string() + format!("invalid type: string \"fals\", expected a boolean for key `boolean_s_parse` in {}", path.to_str().unwrap()) ); } diff --git a/tests/file_hjson.rs b/tests/file_hjson.rs index 086489b..1e99b87 100644 --- a/tests/file_hjson.rs +++ b/tests/file_hjson.rs @@ -10,6 +10,7 @@ extern crate serde_derive; use config::*; use float_cmp::ApproxEqUlps; use std::collections::HashMap; +use std::path::PathBuf; #[derive(Debug, Deserialize)] struct Place { @@ -69,9 +70,11 @@ fn test_error_parse() { let mut c = Config::default(); let res = c.merge(File::new("tests/Settings-invalid", FileFormat::Hjson)); + let path : PathBuf = ["tests", "Settings-invalid.hjson"].iter().collect(); + assert!(res.is_err()); assert_eq!( res.unwrap_err().to_string(), - "Found a punctuator where a key name was expected (check your syntax or use quotes if the key name includes {}[],: or whitespace) at line 4 column 1 in tests/Settings-invalid.hjson".to_string() + format!("Found a punctuator where a key name was expected (check your syntax or use quotes if the key name includes {{}}[],: or whitespace) at line 4 column 1 in {}", path.to_str().unwrap()) ); } diff --git a/tests/file_ini.rs b/tests/file_ini.rs index 833cab0..057e496 100644 --- a/tests/file_ini.rs +++ b/tests/file_ini.rs @@ -8,6 +8,7 @@ extern crate serde; extern crate serde_derive; use config::*; +use std::path::PathBuf; #[derive(Debug, Deserialize, PartialEq)] struct Place { @@ -57,9 +58,11 @@ fn test_error_parse() { let mut c = Config::default(); let res = c.merge(File::new("tests/Settings-invalid", FileFormat::Ini)); + let path : PathBuf = ["tests", "Settings-invalid.ini"].iter().collect(); + 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"# + format!(r#"2:0 Expecting "[Some('='), Some(':')]" but found EOF. in {}"#, path.to_str().unwrap()) ); } diff --git a/tests/file_json.rs b/tests/file_json.rs index 4b586b2..1262585 100644 --- a/tests/file_json.rs +++ b/tests/file_json.rs @@ -10,6 +10,7 @@ extern crate serde_derive; use config::*; use float_cmp::ApproxEqUlps; use std::collections::HashMap; +use std::path::PathBuf; #[derive(Debug, Deserialize)] struct Place { @@ -69,9 +70,11 @@ fn test_error_parse() { let mut c = Config::default(); let res = c.merge(File::new("tests/Settings-invalid", FileFormat::Json)); + let path_with_extension : PathBuf = ["tests", "Settings-invalid.json"].iter().collect(); + assert!(res.is_err()); assert_eq!( res.unwrap_err().to_string(), - "expected `:` at line 4 column 1 in tests/Settings-invalid.json".to_string() + format!("expected `:` at line 4 column 1 in {}", path_with_extension.to_str().unwrap()) ); } diff --git a/tests/file_toml.rs b/tests/file_toml.rs index d1ae5db..a2a1caf 100644 --- a/tests/file_toml.rs +++ b/tests/file_toml.rs @@ -10,6 +10,7 @@ extern crate serde_derive; use config::*; use float_cmp::ApproxEqUlps; use std::collections::HashMap; +use std::path::PathBuf; #[derive(Debug, Deserialize)] struct Place { @@ -79,9 +80,11 @@ fn test_error_parse() { let mut c = Config::default(); let res = c.merge(File::new("tests/Settings-invalid", FileFormat::Toml)); + let path_with_extension : PathBuf = ["tests", "Settings-invalid.toml"].iter().collect(); + assert!(res.is_err()); assert_eq!( res.unwrap_err().to_string(), - "failed to parse datetime for key `error` at line 2 column 9 in tests/Settings-invalid.toml".to_string() + format!("failed to parse datetime for key `error` at line 2 column 9 in {}", path_with_extension.to_str().unwrap()) ); } diff --git a/tests/file_yaml.rs b/tests/file_yaml.rs index 85788c4..efc2908 100644 --- a/tests/file_yaml.rs +++ b/tests/file_yaml.rs @@ -10,6 +10,7 @@ extern crate serde_derive; use config::*; use float_cmp::ApproxEqUlps; use std::collections::HashMap; +use std::path::PathBuf; #[derive(Debug, Deserialize)] struct Place { @@ -69,11 +70,12 @@ fn test_error_parse() { let mut c = Config::default(); let res = c.merge(File::new("tests/Settings-invalid", FileFormat::Yaml)); + let path_with_extension : PathBuf = ["tests", "Settings-invalid.yaml"].iter().collect(); + assert!(res.is_err()); assert_eq!( res.unwrap_err().to_string(), - "while parsing a block mapping, did not find expected key at \ - line 2 column 1 in tests/Settings-invalid.yaml" - .to_string() + format!("while parsing a block mapping, did not find expected key at \ + line 2 column 1 in {}", path_with_extension.to_str().unwrap()) ); } |