@@ -52,17 +52,26 @@ divmod!(__divmoddi4, __divdi3: i64);
52
52
53
53
#[ cfg( test) ]
54
54
mod tests {
55
- use quickcheck:: TestResult ;
56
55
use qc:: { U32 , U64 } ;
57
56
57
+ use gcc_s;
58
+ use quickcheck:: TestResult ;
59
+ use rand;
60
+
58
61
quickcheck ! {
59
62
fn divdi3( n: U64 , d: U64 ) -> TestResult {
60
63
let ( n, d) = ( n. 0 as i64 , d. 0 as i64 ) ;
61
64
if d == 0 {
62
65
TestResult :: discard( )
63
66
} else {
64
67
let q = super :: __divdi3( n, d) ;
65
- TestResult :: from_bool( q == n / d)
68
+
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) ,
74
+ }
66
75
}
67
76
}
68
77
@@ -72,7 +81,13 @@ mod tests {
72
81
TestResult :: discard( )
73
82
} else {
74
83
let r = super :: __moddi3( n, d) ;
75
- TestResult :: from_bool( r == n % d)
84
+
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) ,
90
+ }
76
91
}
77
92
}
78
93
@@ -83,7 +98,18 @@ mod tests {
83
98
} else {
84
99
let mut r = 0 ;
85
100
let q = super :: __divmoddi4( n, d, & mut r) ;
86
- TestResult :: from_bool( q == n / d && r == n % d)
101
+
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
+ } ;
108
+
109
+ TestResult :: from_bool( q == gcc_s_q && r == gcc_s_r)
110
+ } ,
111
+ _ => TestResult :: from_bool( q == n / d && r == n % d) ,
112
+ }
87
113
}
88
114
}
89
115
@@ -93,7 +119,13 @@ mod tests {
93
119
TestResult :: discard( )
94
120
} else {
95
121
let q = super :: __divsi3( n, d) ;
96
- TestResult :: from_bool( q == n / d)
122
+
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) ,
128
+ }
97
129
}
98
130
}
99
131
@@ -103,7 +135,13 @@ mod tests {
103
135
TestResult :: discard( )
104
136
} else {
105
137
let r = super :: __modsi3( n, d) ;
106
- TestResult :: from_bool( r == n % d)
138
+
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) ,
144
+ }
107
145
}
108
146
}
109
147
@@ -114,7 +152,18 @@ mod tests {
114
152
} else {
115
153
let mut r = 0 ;
116
154
let q = super :: __divmodsi4( n, d, & mut r) ;
117
- TestResult :: from_bool( q == n / d && r == n % d)
155
+
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
+ } ;
162
+
163
+ TestResult :: from_bool( q == gcc_s_q && r == gcc_s_r)
164
+ } ,
165
+ _ => TestResult :: from_bool( q == n / d && r == n % d) ,
166
+ }
118
167
}
119
168
}
120
169
}
0 commit comments