proptest_arbitrary/_std/
num.rs1use super::*;
4use std::num::*;
5
6arbitrary!(ParseFloatError; "".parse::<f32>().unwrap_err());
7arbitrary!(ParseIntError; "".parse::<u32>().unwrap_err());
8
9#[cfg(feature = "unstable")]
10arbitrary!(TryFromIntError; {
11 use std::convert::TryFrom;
12 u8::try_from(-1).unwrap_err()
13});
14
15wrap_ctor!(Wrapping, Wrapping);
16
17arbitrary!(FpCategory,
18 TupleUnion<(W<Just<Self>>, W<Just<Self>>, W<Just<Self>>,
19 W<Just<Self>>, W<Just<Self>>)>;
20 {
21 use std::num::FpCategory::*;
22 prop_oneof![
23 Just(Nan),
24 Just(Infinite),
25 Just(Zero),
26 Just(Subnormal),
27 Just(Normal),
28 ]
29 }
30);
31
32#[cfg(test)]
33mod test {
34 no_panic_test!(
35 parse_float_error => ParseFloatError,
36 parse_int_error => ParseIntError,
37 wrapping => Wrapping<u8>,
38 fp_category => FpCategory
39 );
40
41 #[cfg(feature = "unstable")]
42 no_panic_test!(
43 try_from_int_error => TryFromIntError
44 );
45}