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
pub fn bytestring() -> Vec<u8> {
let s = if rand::random::<u8>() % 4 == 0 {
0
} else {
rand::random::<usize>() % 4096
};
let mut bs = Vec::with_capacity(s);
for _ in 1..s {
bs.push(rand::random());
}
bs
}
pub fn non_empty_bytestring() -> Vec<u8> {
let s = (rand::random::<usize>() % 4096) + 1;
let mut bs = Vec::with_capacity(s);
for _ in 1..s {
bs.push(rand::random());
}
bs
}
pub fn string() -> String {
let l = if rand::random::<u8>() % 4 == 0 {
0
} else {
rand::random::<usize>() % 4096
};
let mut s = String::with_capacity(l);
for _ in 0..l {
s.push(rand::random())
}
s
}
pub fn coinflip() -> bool {
rand::random()
}
pub fn usize(n: usize) -> usize {
if rand::random::<u8>() % 4 == 0 {
0
} else {
rand::random::<usize>() % n
}
}