Skip to content

Commit

Permalink
Add test cases for panicking general_section
Browse files Browse the repository at this point in the history
  • Loading branch information
sirhcel authored and zonyitoo committed Mar 26, 2022
1 parent 8ab680e commit a734be3
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1344,6 +1344,18 @@ mod test {
assert!(!props.contains_key("k1"));
}

#[test]
fn load_from_str_with_empty_input() {
let input = "\n\n\n";
let opt = Ini::load_from_str(input);
assert!(opt.is_ok());

let mut output = opt.unwrap();
assert!(output.general_section().is_empty());
assert!(output.general_section_mut().is_empty());
assert_eq!(output.len(), 1);
}

#[test]
#[cfg(not(feature = "brackets-in-section-names"))]
fn load_from_str_with_valid_input() {
Expand Down Expand Up @@ -1933,6 +1945,15 @@ bar = f
assert_eq!(None, iter.next());
}

#[test]
fn new_has_empty_general_section() {
let mut ini = Ini::new();

assert!(ini.general_section().is_empty());
assert!(ini.general_section_mut().is_empty());
assert_eq!(ini.len(), 1);
}

#[test]
fn fix_issue63() {
let section = "PHP";
Expand Down

0 comments on commit a734be3

Please sign in to comment.