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
use crate::std_facade::Vec;
use core::iter::repeat;
use core::str::{from_utf8, ParseBoolError, Utf8Error};
use crate::arbitrary::*;
use crate::strategy::statics::static_map;
use crate::strategy::*;
arbitrary!(ParseBoolError; "".parse::<bool>().unwrap_err());
type ELSeq = WA<Just<&'static [u8]>>;
type ELSeqs = TupleUnion<(ELSeq, ELSeq, ELSeq, ELSeq)>;
fn gen_el_seqs() -> ELSeqs {
prop_oneof![
Just(&[0xC2]),
Just(&[0x80]),
Just(&[0xE0, 0xA0, 0x00]),
Just(&[0xF0, 0x90, 0x80, 0x00])
]
}
arbitrary!(Utf8Error, SFnPtrMap<(StrategyFor<u16>, ELSeqs), Utf8Error>;
static_map((any::<u16>(), gen_el_seqs()), |(vut, elseq)| {
let v = repeat(b'_').take(vut as usize)
.chain(elseq.iter().cloned())
.collect::<Vec<u8>>();
from_utf8(&v).unwrap_err()
})
);
#[cfg(test)]
mod test {
no_panic_test!(
parse_bool_errror => ParseBoolError,
utf8_error => Utf8Error
);
}