From 04294a999f71a5492aba75fe54a89060eb982ae2 Mon Sep 17 00:00:00 2001 From: zonyitoo Date: Thu, 13 Feb 2020 00:40:10 +0800 Subject: [PATCH] Add more tests for replace (insert) --- src/ini.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/ini.rs b/src/ini.rs index 2bd9868..3e90ec4 100644 --- a/src/ini.rs +++ b/src/ini.rs @@ -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::>(); + assert_eq!(res, vec!["v1"]); + + props.insert("k1", "v2"); + assert_eq!(Some("v2"), props.get("k1")); + + let res = props.get_all("k1").collect::>(); + 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::>(); assert_eq!(res, vec!["v1", "v2"]); @@ -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]