Skip to content

Commit

Permalink
review: add tests for empty map (de)serialization.
Browse files Browse the repository at this point in the history
Signed-off-by: Piotr Sikora <code@piotrsikora.dev>
  • Loading branch information
PiotrSikora committed Nov 3, 2024
1 parent 752d43c commit a7b5055
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/hostcalls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1288,6 +1288,34 @@ mod utils {
112, 114, 111, 120, 121, 45, 119, 97, 115, 109, 0,
];

#[test]
fn test_serialize_map_empty() {
let serialized_map = serialize_map(vec![]);
assert_eq!(serialized_map, [0, 0, 0, 0]);
}

#[test]
fn test_serialize_map_empty_bytes() {
let serialized_map = serialize_map_bytes(vec![]);
assert_eq!(serialized_map, [0, 0, 0, 0]);
}

#[test]
fn test_deserialize_map_empty() {
let map = deserialize_map(&[]);
assert_eq!(map, []);
let map = deserialize_map(&[0, 0, 0, 0]);
assert_eq!(map, []);
}

#[test]
fn test_deserialize_map_empty_bytes() {
let map = deserialize_map_bytes(&[]);
assert_eq!(map, []);
let map = deserialize_map_bytes(&[0, 0, 0, 0]);
assert_eq!(map, []);
}

#[test]
fn test_serialize_map() {
let serialized_map = serialize_map(MAP.to_vec());
Expand Down

0 comments on commit a7b5055

Please sign in to comment.