Skip to content

Commit 57dcbfe

Browse files
adpaco-awsdanielsn
authored andcommitted
Add nondet. bytes test (rust-lang#94)
Co-authored-by: Daniel Schwartz-Narbonne <[email protected]>
1 parent 1f71216 commit 57dcbfe

File tree

1 file changed

+27
-0
lines changed
  • rust-tests/cbmc-reg/NondetVectors

1 file changed

+27
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: Apache-2.0 OR MIT
3+
use std::convert::TryInto;
4+
5+
fn __nondet<T>() -> T {
6+
unimplemented!()
7+
}
8+
9+
fn main() {
10+
let input: &[u8] = &vec![
11+
__nondet(),
12+
__nondet(),
13+
__nondet(),
14+
__nondet(),
15+
__nondet(),
16+
__nondet(),
17+
__nondet(),
18+
__nondet(),
19+
];
20+
let buffer = input.as_ref();
21+
let bytes: [u8; 8] = buffer.try_into().unwrap();
22+
let value = u64::from_be_bytes(bytes);
23+
let idx: usize = __nondet();
24+
if idx < 8 {
25+
assert!(u64::to_be_bytes(value)[idx] == input[idx]);
26+
}
27+
}

0 commit comments

Comments
 (0)