From b171205c57f6b8cd7eb3a175946293ab5b41988f Mon Sep 17 00:00:00 2001 From: Bourgond Aries Date: Fri, 25 Mar 2016 17:43:32 +0100 Subject: Add a test to see if the table's contents have changed --- src/lib.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src') diff --git a/src/lib.rs b/src/lib.rs index d81b9cd..8afaa3d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -279,6 +279,28 @@ impl FromStr for Value { mod tests { use super::Value; + #[test] + fn lookup_mut_change() { + let toml = r#" + [test] + foo = "bar" + + [[values]] + foo = "baz" + + [[values]] + foo = "qux" + "#; + + let mut value: Value = toml.parse().unwrap(); + { + let foo = value.lookup_mut("values.0.foo").unwrap(); + *foo = Value::String(String::from("bar")); + } + let foo = value.lookup("values.0.foo").unwrap(); + assert_eq!(foo.as_str().unwrap(), "bar"); + } + #[test] fn lookup_mut_valid() { let toml = r#" -- cgit v1.2.3