Skip to content

Commit

Permalink
add test for chained and separate SectionSetter calls
Browse files Browse the repository at this point in the history
  • Loading branch information
rikyborg committed Aug 2, 2024
1 parent fd67ca5 commit 3decb9b
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2636,4 +2636,37 @@ x3 = nb
]
);
}

#[test]
fn section_setter_chain() {
// fix issue #134

let mut ini = Ini::new();
let mut section_setter = ini.with_section(Some("section"));

// chained set() calls work
section_setter.set("a", "1").set("b", "2");
// separate set() calls work
section_setter.set("c", "3");

assert_eq!("1", section_setter.get("a").unwrap());
assert_eq!("2", section_setter.get("b").unwrap());
assert_eq!("3", section_setter.get("c").unwrap());

// overwrite values
section_setter.set("a", "4").set("b", "5");
section_setter.set("c", "6");

assert_eq!("4", section_setter.get("a").unwrap());
assert_eq!("5", section_setter.get("b").unwrap());
assert_eq!("6", section_setter.get("c").unwrap());

// delete entries
section_setter.delete(&"a").delete(&"b");
section_setter.delete(&"c");

assert!(section_setter.get("a").is_none());
assert!(section_setter.get("b").is_none());
assert!(section_setter.get("c").is_none());
}
}

0 comments on commit 3decb9b

Please sign in to comment.