Skip to content

Commit

Permalink
Add another test
Browse files Browse the repository at this point in the history
  • Loading branch information
adpaco-aws committed Jul 9, 2024
1 parent 61c9fbe commit 087b22b
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tests/expected/attr-invariant/check_arbitrary/check_arbitrary.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright Kani Contributors
// SPDX-License-Identifier: Apache-2.0 OR MIT

//! Check that the `kani::invariant` attribute automatically generates the
//! `Arbitrary` implementation, and also that the values it generates respect
//! the type invariant.

extern crate kani;
use kani::Invariant;

#[kani::invariant(*x >= 0 && *y >= 0)]
struct Point {
x: i32,
y: i32,
}

#[kani::proof]
fn check_arbitrary() {
let point: Point = kani::any();
assert!(point.x >= 0);
assert!(point.y >= 0);
assert!(point.is_safe());
}
11 changes: 11 additions & 0 deletions tests/expected/attr-invariant/check_arbitrary/expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Check 1: check_arbitrary.assertion.1\
- Status: SUCCESS\
- Description: "assertion failed: point.x >= 0"

Check 2: check_arbitrary.assertion.2\
- Status: SUCCESS\
- Description: "assertion failed: point.y >= 0"

Check 3: check_arbitrary.assertion.3\
- Status: SUCCESS\
- Description: "assertion failed: point.is_safe()"

0 comments on commit 087b22b

Please sign in to comment.