Skip to content

Commit 875ecf5

Browse files
add expected tests
1 parent 67d7a4e commit 875ecf5

File tree

6 files changed

+77
-0
lines changed

6 files changed

+77
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
main.assertion.2\
2+
- Status: SUCCESS\
3+
- Description: "assertion failed: unsafe { FOO.a[1] } == 0"
4+
5+
6+
main.assertion.3\
7+
- Status: SUCCESS\
8+
- Description: "assertion failed: unsafe { BAR.b } == 3"\
9+
10+
VERIFICATION:- SUCCESSFUL
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright Kani Contributors
2+
// SPDX-License-Identifier: Apache-2.0 OR MIT
3+
4+
static FOO: Data = Data { a: [0; 3] };
5+
6+
static BAR: Data = Data { b: 3 };
7+
8+
union Data {
9+
a: [u8; 3],
10+
b: u16,
11+
}
12+
13+
#[kani::proof]
14+
fn main() {
15+
let _x = &FOO;
16+
assert!(unsafe { FOO.a[1] } == 0);
17+
assert!(unsafe { BAR.b } == 3);
18+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
main.assertion.1\
2+
- Status: SUCCESS\
3+
- Description: "index out of bounds: the length is less than or equal to the given index"\
4+
5+
Check 2: main.assertion.2\
6+
- Status: FAILURE\
7+
- Description: "assertion failed: unsafe { FOO.a[1] } == 5"\
8+
9+
Failed Checks: assertion failed: unsafe { FOO.a[1] } == 5
10+
11+
VERIFICATION:- FAILED
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright Kani Contributors
2+
// SPDX-License-Identifier: Apache-2.0 OR MIT
3+
4+
static FOO: Data = Data { a: [0; 3] };
5+
6+
union Data {
7+
a: [u8; 3],
8+
b: u16,
9+
}
10+
11+
#[kani::proof]
12+
fn main() {
13+
let _x = &FOO;
14+
assert!(unsafe { FOO.a[1] } == 5);
15+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
main.assertion.1\
2+
- Status: SUCCESS\
3+
- Description: "assertion failed: y == 256"
4+
5+
VERIFICATION:- SUCCESSFUL
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright Kani Contributors
2+
// SPDX-License-Identifier: Apache-2.0 OR MIT
3+
4+
use std::mem::transmute;
5+
6+
static FOO: Data = Data { a: [0, 1, 0] };
7+
8+
#[derive(Copy, Clone)]
9+
union Data {
10+
a: [u8; 3],
11+
b: u16,
12+
}
13+
14+
#[kani::proof]
15+
fn main() {
16+
let y: u32 = unsafe { transmute(FOO) };
17+
assert!(y == 256);
18+
}

0 commit comments

Comments
 (0)