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
53
54
55
56
57
58
59
60
pub use settings_macros::*;

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_defaults() {
        assert_eq!(settings!("made-up", "something", "a value"), "a value");
        assert_eq!(settings!("test", "test", 14798), 14798);
    }

    #[test]
    fn test_strings() {
        assert_eq!(settings!("example-crate", "some-key", "something"), "hey");
    }

    #[test]
    fn test_integers() {
        assert_eq!(settings!("another-crate", "number", 100), 33);
    }

    #[test]
    fn test_floats() {
        assert_eq!(settings!("another-crate", "float"), 55.6);
    }

    #[test]
    fn test_date_times() {
        assert_eq!(
            settings!("cool_crate", "some_date_time"),
            "1979-05-27T07:32:00Z"
        )
    }

    #[test]
    fn test_bools() {
        assert_eq!(settings!("example-crate", "something_else"), false);
    }

    #[test]
    fn test_string_arrays() {
        assert_eq!(settings!("another-crate", "arr"), ["a", "b", "c"]);
    }

    #[test]
    fn test_mixed_arrays() {
        // mixed arrays get automatically loaded as string arrays
        assert_eq!(settings!("weird_crate", "mixed_arr"), ["hey", "1", "false"]);
    }

    #[test]
    fn test_tables() {
        // tables get automatically converted to strings
        assert_eq!(
            settings!("weird_crate", "table"),
            "{ key1 = \"hey\", key2 = 3 }"
        )
    }
}