Skip to content

Commit 1546116

Browse files
committed
Add tests
1 parent 27c9a0b commit 1546116

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

serialize/src/test.rs

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use std::collections::{HashMap, HashSet};
2+
13
use super::*;
24
use ark_std::{
35
collections::{BTreeMap, BTreeSet, LinkedList, VecDeque},
@@ -8,7 +10,7 @@ use ark_std::{
810
};
911
use num_bigint::BigUint;
1012

11-
#[derive(Copy, Clone, Ord, PartialOrd, Eq, PartialEq, Debug)]
13+
#[derive(Copy, Clone, Ord, PartialOrd, Eq, PartialEq, Debug, Hash)]
1214
struct Dummy;
1315

1416
impl CanonicalSerialize for Dummy {
@@ -286,6 +288,31 @@ fn test_btreeset() {
286288
test_serialize(set);
287289
}
288290

291+
#[test]
292+
#[allow(clippy::zero_sized_map_values)]
293+
fn test_hashmap() {
294+
let mut map = HashMap::new();
295+
map.insert(0u64, Dummy);
296+
map.insert(5u64, Dummy);
297+
test_serialize(map);
298+
let mut map = BTreeMap::new();
299+
map.insert(10u64, vec![1u8, 2u8, 3u8]);
300+
map.insert(50u64, vec![4u8, 5u8, 6u8]);
301+
test_serialize(map);
302+
}
303+
304+
#[test]
305+
fn test_hashset() {
306+
let mut set = HashSet::new();
307+
set.insert(Dummy);
308+
set.insert(Dummy);
309+
test_serialize(set);
310+
let mut set = BTreeSet::new();
311+
set.insert(vec![1u8, 2u8, 3u8]);
312+
set.insert(vec![4u8, 5u8, 6u8]);
313+
test_serialize(set);
314+
}
315+
289316
#[test]
290317
fn test_phantomdata() {
291318
test_serialize(core::marker::PhantomData::<Dummy>);

0 commit comments

Comments
 (0)