Skip to content

Commit

Permalink
Add more tests for replace (insert)
Browse files Browse the repository at this point in the history
  • Loading branch information
zonyitoo committed Feb 12, 2020
1 parent 350e894 commit 04294a9
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/ini.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1173,12 +1173,33 @@ impl<'a> Parser<'a> {
mod test {
use super::*;

#[test]
fn property_replace() {
let mut props = Properties::new();
props.insert("k1", "v1");

assert_eq!(Some("v1"), props.get("k1"));
let res = props.get_all("k1").collect::<Vec<&str>>();
assert_eq!(res, vec!["v1"]);

props.insert("k1", "v2");
assert_eq!(Some("v2"), props.get("k1"));

let res = props.get_all("k1").collect::<Vec<&str>>();
assert_eq!(res, vec!["v2"]);
}

#[test]
fn property_get_vec() {
let mut props = Properties::new();
props.append("k1", "v1");

assert_eq!(Some("v1"), props.get("k1"));

props.append("k1", "v2");

assert_eq!(Some("v1"), props.get("k1"));

let res = props.get_all("k1").collect::<Vec<&str>>();
assert_eq!(res, vec!["v1", "v2"]);

Expand Down Expand Up @@ -1685,6 +1706,8 @@ bar = f
assert_eq!(Some("Peer"), k3);
assert_eq!(Some("e"), p3.get("foo"));
assert_eq!(Some("f"), p3.get("bar"));

assert_eq!(None, iter.next());
}

#[test]
Expand Down

0 comments on commit 04294a9

Please sign in to comment.