Add a test to see if the table's contents have changed
This commit is contained in:
parent
32969ca891
commit
b171205c57
22
src/lib.rs
22
src/lib.rs
|
@ -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#"
|
||||||
|
|
Loading…
Reference in a new issue