Add a test to see if the table's contents have changed

This commit is contained in:
Bourgond Aries 2016-03-25 17:43:32 +01:00
parent 32969ca891
commit b171205c57

View file

@ -279,6 +279,28 @@ impl FromStr for Value {
mod tests { mod tests {
use super::Value; 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] #[test]
fn lookup_mut_valid() { fn lookup_mut_valid() {
let toml = r#" let toml = r#"