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
45
46
47
48
49
50
51
52
|
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_eq!(c.get("debug").ok(), Some(true));
assert_eq!(c.get("production").ok(), Some(false));
}
#[test]
fn test_scalar_type_loose() {
let c = make();
assert_eq!(c.get("debug").ok(), Some(true));
assert_eq!(c.get("debug").ok(), Some("true".to_string()));
assert_eq!(c.get("debug").ok(), Some(1));
assert_eq!(c.get("debug").ok(), Some(1.0));
assert_eq!(c.get("debug_s").ok(), Some(true));
assert_eq!(c.get("debug_s").ok(), Some("true".to_string()));
assert_eq!(c.get("debug_s").ok(), Some(1));
assert_eq!(c.get("debug_s").ok(), Some(1.0));
assert_eq!(c.get("production").ok(), Some(false));
assert_eq!(c.get("production").ok(), Some("false".to_string()));
assert_eq!(c.get("production").ok(), Some(0));
assert_eq!(c.get("production").ok(), Some(0.0));
assert_eq!(c.get("production_s").ok(), Some(false));
assert_eq!(c.get("production_s").ok(), Some("false".to_string()));
assert_eq!(c.get("production_s").ok(), Some(0));
assert_eq!(c.get("production_s").ok(), Some(0.0));
}
#[test]
fn test_get_scalar_path() {
let c = make();
assert_eq!(c.get("place.favorite").ok(), Some(false));
assert_eq!(c.get("place.creator.name").ok(), Some("John Smith".to_string()));
}
|