Skip to content

Commit

Permalink
Bump those coverage numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelsproul committed Jul 8, 2024
1 parent d172c48 commit 37a89f3
Showing 1 changed file with 42 additions and 1 deletion.
43 changes: 42 additions & 1 deletion ssz/tests/tests.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
use ethereum_types::H256;
use ethereum_types::{H160, H256};
use ssz::{Decode, DecodeError, Encode};
use ssz_derive::{Decode, Encode};

mod round_trip {
use super::*;
use std::collections::BTreeMap;
use std::iter::FromIterator;
use std::num::NonZeroUsize;
use std::sync::Arc;

fn round_trip<T: Encode + Decode + std::fmt::Debug + PartialEq>(items: Vec<T>) {
for item in items {
Expand Down Expand Up @@ -36,6 +38,23 @@ mod round_trip {
round_trip(items);
}

#[test]
fn h160() {
let items: Vec<H160> = vec![H160::zero(), H160::from([1; 20]), H160::random()];

round_trip(items);
}

#[test]
fn vec_of_h160() {
let items: Vec<Vec<H160>> = vec![
vec![],
vec![H160::zero(), H160::from([1; 20]), H160::random()],
];

round_trip(items);
}

#[test]
fn h256() {
let items: Vec<H256> = vec![H256::zero(), H256::from([1; 32]), H256::random()];
Expand Down Expand Up @@ -387,4 +406,26 @@ mod round_trip {
];
round_trip(data);
}

#[test]
fn non_zero_usize() {
let data = vec![
NonZeroUsize::new(1).unwrap(),
NonZeroUsize::new(u16::MAX as usize).unwrap(),
NonZeroUsize::new(usize::MAX).unwrap(),
];
round_trip(data);
}

#[test]
fn arc_u64() {
let data = vec![Arc::new(0u64), Arc::new(u64::MAX)];
round_trip(data);
}

#[test]
fn arc_vec_u64() {
let data = vec![Arc::new(vec![0u64]), Arc::new(vec![u64::MAX; 10])];
round_trip(data);
}
}

0 comments on commit 37a89f3

Please sign in to comment.