Skip to content

Commit

Permalink
Add test for testing value type
Browse files Browse the repository at this point in the history
Signed-off-by: Matthias Beyer <[email protected]>
  • Loading branch information
matthiasbeyer committed Mar 19, 2021
1 parent 7562227 commit 9953c9b
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
}
}
1 change: 1 addition & 0 deletions tests/types/i64.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
value = 120

0 comments on commit 9953c9b

Please sign in to comment.