Modify push test

Cargo mutants found mutants in witness.

Add to the existing test `push` to kill the mutants from `is_empty` and
`third_to_last`.

Change the dummy values to make the progression of `elements` down the
test easier to follow.
This commit is contained in:
Jamil Lambert, PhD 2025-02-11 16:37:31 +00:00
parent 9c3a52be88
commit 3ee66c5bb8
No known key found for this signature in database
GPG Key ID: 54DC29234AB5D2C0
1 changed files with 9 additions and 6 deletions

View File

@ -497,6 +497,7 @@ mod test {
fn push() {
// Sanity check default.
let mut witness = Witness::default();
assert!(witness.is_empty());
assert_eq!(witness.last(), None);
assert_eq!(witness.second_to_last(), None);
@ -506,10 +507,11 @@ mod test {
assert_eq!(witness.nth(3), None);
// Push a single byte element onto the witness stack.
let push = [0_u8];
let push = [11_u8];
witness.push(push);
assert!(!witness.is_empty());
let elements = [1u8, 0];
let elements = [1u8, 11];
let expected = Witness {
witness_elements: 1,
content: append_u32_vec(&elements, &[0]), // Start at index 0.
@ -529,10 +531,10 @@ mod test {
assert_eq!(witness.nth(3), None);
// Now push 2 byte element onto the witness stack.
let push = [2u8, 3u8];
let push = [21u8, 22u8];
witness.push(push);
let elements = [1u8, 0, 2, 2, 3];
let elements = [1u8, 11, 2, 21, 22];
let expected = Witness {
witness_elements: 2,
content: append_u32_vec(&elements, &[0, 2]),
@ -552,10 +554,10 @@ mod test {
assert_eq!(witness.last(), Some(element_1));
// Now push another 2 byte element onto the witness stack.
let push = [4u8, 5u8];
let push = [31u8, 32u8];
witness.push(push);
let elements = [1u8, 0, 2, 2, 3, 2, 4, 5];
let elements = [1u8, 11, 2, 21, 22, 2, 31, 32];
let expected = Witness {
witness_elements: 3,
content: append_u32_vec(&elements, &[0, 2, 5]),
@ -571,6 +573,7 @@ mod test {
assert_eq!(witness.nth(2), Some(element_2));
assert_eq!(witness.nth(3), None);
assert_eq!(witness.third_to_last(), Some(element_0));
assert_eq!(witness.second_to_last(), Some(element_1));
assert_eq!(witness.last(), Some(element_2));
}