Add from impl tests

Add tests for the witness from implementations to kill all the mutants
found by cargo mutants.
This commit is contained in:
Jamil Lambert, PhD 2025-02-11 17:31:24 +00:00
parent 2f95064cfd
commit 7e66091e1e
No known key found for this signature in database
GPG Key ID: 54DC29234AB5D2C0
1 changed files with 27 additions and 0 deletions

View File

@ -609,6 +609,33 @@ mod test {
assert_eq!(witness.size(), 6); assert_eq!(witness.size(), 6);
} }
#[test]
fn witness_from_impl() {
// Test From implementations with the same 2 elements
let vec = vec![vec![11], vec![21, 22]];
let slice_vec: &[Vec<u8>] = &vec;
let slice_slice: &[&[u8]] = &[&[11u8], &[21, 22]];
let vec_slice: Vec<&[u8]> = vec![&[11u8], &[21, 22]];
let witness_vec_vec = Witness::from(vec.clone());
let witness_slice_vec = Witness::from(slice_vec);
let witness_slice_slice = Witness::from(slice_slice);
let witness_vec_slice = Witness::from(vec_slice);
let mut expected = Witness::from_slice(&vec);
assert_eq!(expected.len(), 2);
assert_eq!(expected.to_vec(), vec);
assert_eq!(witness_vec_vec, expected);
assert_eq!(witness_slice_vec, expected);
assert_eq!(witness_slice_slice, expected);
assert_eq!(witness_vec_slice, expected);
// Test clear method
expected.clear();
assert!(expected.is_empty());
}
#[test] #[test]
#[cfg(feature = "serde")] #[cfg(feature = "serde")]
fn serde_bincode_backward_compatibility() { fn serde_bincode_backward_compatibility() {