summaryrefslogtreecommitdiffstats
path: root/tests/scalar.rs
blob: 82a4148daead0c7b231fc23ffa2925a629e31167 (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
32
33
34
35
36
37
38
39
40
41
42
43
44
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_scalar() {
    let c = make();

    assert!(c.get("debug").ok() == Some(true));
    assert!(c.get("production").ok() == Some(false));
}

#[test]
fn test_scalar_type_loose() {
    let c = make();

    assert!(c.get("debug").ok() == Some(true));
    assert!(c.get("debug").ok() == Some("true".to_string()));
    assert!(c.get("debug").ok() == Some(1));
    assert!(c.get("debug").ok() == Some(1.0));

    assert!(c.get("debug_s").ok() == Some(true));
    assert!(c.get("debug_s").ok() == Some("true".to_string()));
    assert!(c.get("debug_s").ok() == Some(1));
    assert!(c.get("debug_s").ok() == Some(1.0));

    assert!(c.get("production").ok() == Some(false));
    assert!(c.get("production").ok() == Some("false".to_string()));
    assert!(c.get("production").ok() == Some(0));
    assert!(c.get("production").ok() == Some(0.0));

    assert!(c.get("production_s").ok() == Some(false));
    assert!(c.get("production_s").ok() == Some("false".to_string()));
    assert!(c.get("production_s").ok() == Some(0));
    assert!(c.get("production_s").ok() == Some(0.0));
}