diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2021-03-18 13:19:00 +0100 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2021-11-21 12:20:21 +0100 |
commit | 3c591e3ea2a79bd64ff2cf28e9f9e37cceec9a18 (patch) | |
tree | eacfec7951402bcb6f9c33273536970c80857505 /src | |
parent | f4424668191d1ae421127770eda1ad894dd01802 (diff) |
Add test for testing value type
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Diffstat (limited to 'src')
-rw-r--r-- | src/value.rs | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/value.rs b/src/value.rs index 8569546..31aebab 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 + ); + } +} |