summaryrefslogtreecommitdiffstats
path: root/tests/scalar.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/scalar.rs')
-rw-r--r--tests/scalar.rs44
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/scalar.rs b/tests/scalar.rs
new file mode 100644
index 0000000..82a4148
--- /dev/null
+++ b/tests/scalar.rs
@@ -0,0 +1,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));
+}