Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Matias Scharager committed Jun 25, 2024
1 parent 33be618 commit 3437710
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
assertion\
- Status: SUCCESS\
- Description: "|_| x.into_iter().map(|v| *v == 0).fold(true,|a,b|a&b)"\

VERIFICATION:- SUCCESSFUL
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright Kani Contributors
// SPDX-License-Identifier: Apache-2.0 OR MIT
// kani-flags: -Zfunction-contracts

// Test that modifies a slice of nondeterministic size

#[kani::modifies(x)]
#[kani::ensures(|_| x.into_iter().map(|v| *v == 0).fold(true,|a,b|a&b))]
fn zero(x: &mut [u8]) {
x.fill(0)
}

#[kani::proof_for_contract(zero)]
fn harness() {
let mut x = [0..kani::any()].map(|_| kani::any());
zero(&mut x);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
assertion\
- Status: SUCCESS\
- Description: "|_| x.into_iter().map(|v| *v == 0).fold(true,|a,b|a&b)"\

VERIFICATION:- SUCCESSFUL
17 changes: 17 additions & 0 deletions tests/expected/function-contract/modifies_slice/u8slice.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright Kani Contributors
// SPDX-License-Identifier: Apache-2.0 OR MIT
// kani-flags: -Zfunction-contracts

// Test that modifies a slice containing bytesize data

#[kani::modifies(x)]
#[kani::ensures(|_| x.into_iter().map(|v| *v == 0).fold(true,|a,b|a&b))]
fn zero(x: &mut [u8]) {
x.fill(0)
}

#[kani::proof_for_contract(zero)]
fn harness() {
let mut x = [kani::any(), kani::any(), kani::any()];
zero(&mut x);
}

0 comments on commit 3437710

Please sign in to comment.