summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2021-03-18 13:19:00 +0100
committerMatthias Beyer <mail@beyermatthias.de>2021-07-10 15:36:15 +0200
commit4b21043c8c5ce28593ae0a92d84daacc815a9728 (patch)
treefce53977a704c60631a6352d9151a4232dd2db61
parentee94342240ff5da47e84a665dba16546cf758316 (diff)
Add test for testing value type
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
-rw-r--r--src/value.rs29
-rw-r--r--tests/types/i64.toml1
2 files changed, 30 insertions, 0 deletions
diff --git a/src/value.rs b/src/value.rs
index a4bc57a..a584bda 100644
--- a/src/value.rs
+++ b/src/value.rs
@@ -693,3 +693,32 @@ impl Display for Value {
write!(f, "{}", self.kind)
}
}
+
+#[cfg(test)]
+mod tests {
+ use super::Value;
+ use super::ValueKind;
+ use crate::Config;
+ use crate::File;
+ use crate::FileFormat;
+
+ #[test]
+ fn test_i64() {
+ let mut c = Config::default();
+ c.merge(File::new("tests/types/i64.toml", FileFormat::Toml))
+ .unwrap();
+
+ assert!(std::matches!(c.cache.kind, ValueKind::Table(_)));
+ let v = match c.cache.kind {
+ ValueKind::Table(t) => t,
+ _ => unreachable!(),
+ };
+
+ let value = v.get("value").unwrap();
+ assert!(
+ std::matches!(value.kind, ValueKind::I64(120)),
+ "Is not a i64(120): {:?}",
+ value.kind
+ );
+ }
+}
diff --git a/tests/types/i64.toml b/tests/types/i64.toml
new file mode 100644
index 0000000..4ad173a
--- /dev/null
+++ b/tests/types/i64.toml
@@ -0,0 +1 @@
+value = 120