@@ -52,9 +52,11 @@ divmod!(__divmoddi4, __divdi3: i64);
52
52
53
53
#[ cfg( test) ]
54
54
mod tests {
55
+ use qc:: { U32 , U64 } ;
56
+
55
57
use gcc_s;
56
58
use quickcheck:: TestResult ;
57
- use qc :: { U32 , U64 } ;
59
+ use rand ;
58
60
59
61
quickcheck ! {
60
62
fn divdi3( n: U64 , d: U64 ) -> TestResult {
@@ -64,10 +66,11 @@ mod tests {
64
66
} else {
65
67
let q = super :: __divdi3( n, d) ;
66
68
67
- if let Some ( divdi3) = gcc_s:: divdi3( ) {
68
- TestResult :: from_bool( q == unsafe { divdi3( n, d) } )
69
- } else {
70
- TestResult :: from_bool( q == n / d)
69
+ match gcc_s:: divdi3( ) {
70
+ Some ( divdi3) if rand:: random( ) => {
71
+ TestResult :: from_bool( q == unsafe { divdi3( n, d) } )
72
+ } ,
73
+ _ => TestResult :: from_bool( q == n / d) ,
71
74
}
72
75
}
73
76
}
@@ -79,10 +82,11 @@ mod tests {
79
82
} else {
80
83
let r = super :: __moddi3( n, d) ;
81
84
82
- if let Some ( moddi3) = gcc_s:: moddi3( ) {
83
- TestResult :: from_bool( r == unsafe { moddi3( n, d) } )
84
- } else {
85
- TestResult :: from_bool( r == n % d)
85
+ match gcc_s:: moddi3( ) {
86
+ Some ( moddi3) if rand:: random( ) => {
87
+ TestResult :: from_bool( r == unsafe { moddi3( n, d) } )
88
+ } ,
89
+ _ => TestResult :: from_bool( r == n % d) ,
86
90
}
87
91
}
88
92
}
@@ -95,15 +99,16 @@ mod tests {
95
99
let mut r = 0 ;
96
100
let q = super :: __divmoddi4( n, d, & mut r) ;
97
101
98
- if let Some ( divmoddi4) = gcc_s:: divmoddi4( ) {
99
- let mut gcc_s_r = 0 ;
100
- let gcc_s_q = unsafe {
101
- divmoddi4( n, d, & mut gcc_s_r)
102
- } ;
102
+ match gcc_s:: divmoddi4( ) {
103
+ Some ( divmoddi4) if rand:: random( ) => {
104
+ let mut gcc_s_r = 0 ;
105
+ let gcc_s_q = unsafe {
106
+ divmoddi4( n, d, & mut gcc_s_r)
107
+ } ;
103
108
104
- TestResult :: from_bool( q == gcc_s_q && r == gcc_s_r)
105
- } else {
106
- TestResult :: from_bool( q == n / d && r == n % d)
109
+ TestResult :: from_bool( q == gcc_s_q && r == gcc_s_r)
110
+ } ,
111
+ _ => TestResult :: from_bool( q == n / d && r == n % d) ,
107
112
}
108
113
}
109
114
}
@@ -115,10 +120,11 @@ mod tests {
115
120
} else {
116
121
let q = super :: __divsi3( n, d) ;
117
122
118
- if let Some ( divsi3) = gcc_s:: divsi3( ) {
119
- TestResult :: from_bool( q == unsafe { divsi3( n, d) } )
120
- } else {
121
- TestResult :: from_bool( q == n / d)
123
+ match gcc_s:: divsi3( ) {
124
+ Some ( divsi3) if rand:: random( ) => {
125
+ TestResult :: from_bool( q == unsafe { divsi3( n, d) } )
126
+ } ,
127
+ _ => TestResult :: from_bool( q == n / d) ,
122
128
}
123
129
}
124
130
}
@@ -130,10 +136,11 @@ mod tests {
130
136
} else {
131
137
let r = super :: __modsi3( n, d) ;
132
138
133
- if let Some ( modsi3) = gcc_s:: modsi3( ) {
134
- TestResult :: from_bool( r == unsafe { modsi3( n, d) } )
135
- } else {
136
- TestResult :: from_bool( r == n % d)
139
+ match gcc_s:: modsi3( ) {
140
+ Some ( modsi3) if rand:: random( ) => {
141
+ TestResult :: from_bool( r == unsafe { modsi3( n, d) } )
142
+ } ,
143
+ _ => TestResult :: from_bool( r == n % d) ,
137
144
}
138
145
}
139
146
}
@@ -146,15 +153,16 @@ mod tests {
146
153
let mut r = 0 ;
147
154
let q = super :: __divmodsi4( n, d, & mut r) ;
148
155
149
- if let Some ( divmodsi4) = gcc_s:: divmodsi4( ) {
150
- let mut gcc_s_r = 0 ;
151
- let gcc_s_q = unsafe {
152
- divmodsi4( n, d, & mut gcc_s_r)
153
- } ;
156
+ match gcc_s:: divmodsi4( ) {
157
+ Some ( divmodsi4) if rand:: random( ) => {
158
+ let mut gcc_s_r = 0 ;
159
+ let gcc_s_q = unsafe {
160
+ divmodsi4( n, d, & mut gcc_s_r)
161
+ } ;
154
162
155
- TestResult :: from_bool( q == gcc_s_q && r == gcc_s_r)
156
- } else {
157
- TestResult :: from_bool( q == n / d && r == n % d)
163
+ TestResult :: from_bool( q == gcc_s_q && r == gcc_s_r)
164
+ } ,
165
+ _ => TestResult :: from_bool( q == n / d && r == n % d) ,
158
166
}
159
167
}
160
168
}
0 commit comments