summaryrefslogtreecommitdiffstats
path: root/tests/errors.rs
blob: b69774c77ba7a6208ceff1c12bf8ca1c46bb043e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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());
}