diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Settings.invalid.toml | 2 | ||||
-rw-r--r-- | tests/Settings.toml | 3 | ||||
-rw-r--r-- | tests/errors.rs | 31 |
3 files changed, 36 insertions, 0 deletions
diff --git a/tests/Settings.invalid.toml b/tests/Settings.invalid.toml new file mode 100644 index 0000000..4d159a4 --- /dev/null +++ b/tests/Settings.invalid.toml @@ -0,0 +1,2 @@ +ok = true +error = tru diff --git a/tests/Settings.toml b/tests/Settings.toml index f0d2547..58ff5f1 100644 --- a/tests/Settings.toml +++ b/tests/Settings.toml @@ -3,6 +3,9 @@ debug_s = "true" production = false production_s = "false" +# errors +boolean_s_parse = "fals" + [place] name = "Torre di Pisa" longitude = 43.7224985 diff --git a/tests/errors.rs b/tests/errors.rs new file mode 100644 index 0000000..b69774c --- /dev/null +++ b/tests/errors.rs @@ -0,0 +1,31 @@ +extern crate config; + +use config::*; + +fn make() -> Config { + let mut c = Config::default(); + c.merge(File::new("tests/Settings", FileFormat::Toml)) + .unwrap(); + + c +} + +#[test] +fn test_error_parse() { + let mut c = Config::default(); + c.merge(File::new("tests/Settings.invalid", FileFormat::Toml)) + .unwrap(); + + assert!(false) +} + +#[test] +fn test_error_type_bool() { + let c = make(); + + let err = c.get::<bool>("boolean_s_parse"); + + assert!(err.is_err()); + assert_eq!(err.unwrap_err().to_string(), + "invalid type: string \"fals\", expected a boolean from tests/Settings.toml".to_string()); +} |