From 53b8bf74381dc292834a356e4a760755d64fc60e Mon Sep 17 00:00:00 2001 From: rdkt13 Date: Sun, 6 Sep 2020 11:23:18 +0200 Subject: Fix paths in tests expectations for all platforms --- tests/errors.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'tests/errors.rs') 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::("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()) ); } -- cgit v1.2.3 From 79f5254c3926431063d0b2d6ffbd8154984a22ef Mon Sep 17 00:00:00 2001 From: rdkt13 Date: Mon, 7 Sep 2020 23:37:59 +0200 Subject: Use `display` method on PathBuf in tests --- tests/errors.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/errors.rs') diff --git a/tests/errors.rs b/tests/errors.rs index 159473e..3a626c7 100644 --- a/tests/errors.rs +++ b/tests/errors.rs @@ -26,7 +26,7 @@ fn test_error_parse() { assert!(res.is_err()); assert_eq!( res.unwrap_err().to_string(), - format!("failed to parse datetime for key `error` at line 2 column 9 in {}", path.to_str().unwrap()) + format!("failed to parse datetime for key `error` at line 2 column 9 in {}", path.display()) ); } @@ -41,7 +41,7 @@ fn test_error_type() { assert!(res.is_err()); assert_eq!( res.unwrap_err().to_string(), - format!("invalid type: string \"fals\", expected a boolean for key `boolean_s_parse` in {}", path.to_str().unwrap()) + format!("invalid type: string \"fals\", expected a boolean for key `boolean_s_parse` in {}", path.display()) ); } -- cgit v1.2.3