Skip to content

Commit

Permalink
Add unit test to cover extend
Browse files Browse the repository at this point in the history
Signed-off-by: Xudong Sun <[email protected]>
  • Loading branch information
marshtompsxd committed Sep 13, 2023
1 parent 6bc09cd commit dd1712c
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/unit_tests/kubernetes_api_objects/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Copyright 2022 VMware, Inc.
// SPDX-License-Identifier: MIT
pub mod object_meta;
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ verus! {
#[test]
#[verifier(external)]
pub fn test_set_name() {
println!("Testing set_name()...");
let mut object_meta = ObjectMeta::default();
object_meta.set_name(new_strlit("name").to_string());
assert_eq!("name".to_string(), object_meta.into_kube().name.unwrap());
Expand Down
4 changes: 2 additions & 2 deletions src/unit_tests/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2022 VMware, Inc.
// SPDX-License-Identifier: MIT
pub mod object_meta;

pub mod kubernetes_api_objects;
pub mod vstd_ext;
3 changes: 3 additions & 0 deletions src/unit_tests/vstd_ext/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Copyright 2022 VMware, Inc.
// SPDX-License-Identifier: MIT
pub mod string_map;
28 changes: 28 additions & 0 deletions src/unit_tests/vstd_ext/string_map.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Copyright 2022 VMware, Inc.
// SPDX-License-Identifier: MIT
use crate::pervasive_ext::string_map::*;
use vstd::prelude::*;
use vstd::string::*;

verus! {

#[test]
#[verifier(external)]
pub fn test_extend() {
let mut m = StringMap::empty();
m.insert(new_strlit("key1").to_string(), new_strlit("val1").to_string());
m.insert(new_strlit("key2").to_string(), new_strlit("val2").to_string());

let mut m2 = StringMap::empty();
m.insert(new_strlit("key1").to_string(), new_strlit("new_val1").to_string());
m.insert(new_strlit("key3").to_string(), new_strlit("val3").to_string());

m.extend(m2);

let rust_map = m.into_rust_map();
assert_eq!(rust_map.get(&"key1".to_string()), Some(&"new_val1".to_string()));
assert_eq!(rust_map.get(&"key2".to_string()), Some(&"val2".to_string()));
assert_eq!(rust_map.get(&"key3".to_string()), Some(&"val3".to_string()));
}

}

0 comments on commit dd1712c

Please sign in to comment.