-
Notifications
You must be signed in to change notification settings - Fork 208
Expand file tree
/
Copy pathbyte_char.rs
More file actions
114 lines (95 loc) · 2.87 KB
/
Copy pathbyte_char.rs
File metadata and controls
114 lines (95 loc) · 2.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#![feature(rustc_private)]
#[macro_use]
mod common;
use common::*;
test_verify_one_file! {
#[test] byte_char_literals verus_code! {
const ZERO: u8 = b'\x00';
const SPACE: u8 = b' ';
const GREATER_THAN: u8 = b'>';
const MAX: u8 = b'\xff';
proof fn values() {
assert(b'\x00' == 0u8);
assert(b' ' == 0x20u8);
assert(b'>' == 0x3eu8);
assert(b'\xff' == 255u8);
assert(ZERO == 0u8);
assert(SPACE == 0x20u8);
assert(GREATER_THAN == 0x3eu8);
assert(MAX == 255u8);
}
fn is_separator(d: u8) -> (result: bool)
ensures
result == (d == 0x20u8 || d == 0x3eu8),
{
d == b' ' || d == b'>'
}
} => Ok(())
}
test_verify_one_file! {
#[test] byte_char_set_literal_0 verus_code! {
use vstd::set::*;
proof fn empty() {
let s1: Set<u8> = set![];
let s2: Set<u8> = set![];
assert(s1 =~= s2);
}
} => Ok(())
}
test_verify_one_file! {
#[test] byte_char_set_literal_1 verus_code! {
use vstd::set::*;
proof fn singleton() {
let s1: Set<u8> = set![b' '];
let s2: Set<u8> = set![0x20u8];
assert(s1 =~= s2);
}
proof fn escaped_singleton() {
let s1: Set<u8> = set![b'\xff'];
let s2: Set<u8> = set![255u8];
assert(s1 =~= s2);
}
} => Ok(())
}
test_verify_one_file! {
#[test] byte_char_set_literal_2 verus_code! {
use vstd::set::*;
proof fn two_elements() {
let s1: Set<u8> = set![b' ', b'>'];
let s2: Set<u8> = set![b'>', b' '];
assert(s1 =~= s2);
assert(s1.contains(0x20u8));
assert(s1.contains(0x3eu8));
}
proof fn comma_at_end() {
let s1: Set<u8> = set![b' ', b'>',];
let s2: Set<u8> = set![b'>', b' ',];
assert(s1 =~= s2);
}
} => Ok(())
}
test_verify_one_file! {
#[test] byte_char_seq_literals verus_code! {
use vstd::seq::*;
proof fn ascii() {
let s: Seq<u8> = seq![b'R', b'I', b'F', b'F'];
assert(s.len() == 4);
assert(s.index(0) == 0x52u8);
assert(s.index(1) == 0x49u8);
assert(s.index(2) == 0x46u8);
assert(s.index(3) == 0x46u8);
}
proof fn escaped() {
let s: Seq<u8> = seq![b'\x00', b' ', b'>', b'\xff'];
assert(s.index(0) == 0u8);
assert(s.index(1) == 0x20u8);
assert(s.index(2) == 0x3eu8);
assert(s.index(3) == 255u8);
}
proof fn comma_at_end() {
let s: Seq<u8> = seq![b'R', b'I', b'F', b'F',];
assert(s.len() == 4);
assert(s.index(2) == 0x46u8);
}
} => Ok(())
}