File tree 1 file changed +28
-7
lines changed
1 file changed +28
-7
lines changed Original file line number Diff line number Diff line change @@ -20,7 +20,18 @@ macro_rules! arbitrary {
20
20
fn arbitrary<G >( g: & mut G ) -> $TY
21
21
where G : Gen
22
22
{
23
- $TY( g. gen ( ) )
23
+ // NOTE Generate edge cases with a 10% chance
24
+ let t = if g. gen_weighted_bool( 10 ) {
25
+ * g. choose( & [
26
+ $ty:: min_value( ) ,
27
+ 0 ,
28
+ $ty:: max_value( ) ,
29
+ ] ) . unwrap( )
30
+ } else {
31
+ g. gen ( )
32
+ } ;
33
+
34
+ $TY( t)
24
35
}
25
36
26
37
fn shrink( & self ) -> Box <Iterator <Item =$TY>> {
@@ -76,13 +87,23 @@ macro_rules! arbitrary_large {
76
87
fn arbitrary<G >( g: & mut G ) -> $TY
77
88
where G : Gen
78
89
{
79
- if g. gen ( ) {
80
- $TY( $ty:: from_parts( g. gen ( ) , g. gen ( ) ) )
81
- } else if g. gen ( ) {
82
- $TY( $ty:: from_parts( 0 , g. gen ( ) ) )
90
+ // NOTE Generate edge cases with a 10% chance
91
+ let t = if g. gen_weighted_bool( 10 ) {
92
+ * g. choose( & [
93
+ $ty:: min_value( ) ,
94
+ 0 ,
95
+ $ty:: max_value( ) ,
96
+ ] ) . unwrap( )
83
97
} else {
84
- $TY( $ty:: from_parts( g. gen ( ) , 0 ) )
85
- }
98
+ match g. gen_range( 0 , 3 ) {
99
+ 0 => $ty:: from_parts( g. gen ( ) , g. gen ( ) ) ,
100
+ 1 => $ty:: from_parts( 0 , g. gen ( ) ) ,
101
+ 2 => $ty:: from_parts( g. gen ( ) , 0 ) ,
102
+ _ => unreachable!( ) ,
103
+ }
104
+ } ;
105
+
106
+ $TY( t)
86
107
}
87
108
88
109
fn shrink( & self ) -> Box <Iterator <Item =$TY>> {
You can’t perform that action at this time.
0 commit comments