@@ -177,4 +177,61 @@ mod tests {
177
177
test_impl_from ! { test_u16i32, u16 , i32 }
178
178
test_impl_from ! { test_u16i64, u16 , i64 }
179
179
test_impl_from ! { test_u32i64, u32 , i64 }
180
+
181
+ // Signed -> Float
182
+ test_impl_from ! { test_i8f32, i8 , f32 }
183
+ test_impl_from ! { test_i8f64, i8 , f64 }
184
+ test_impl_from ! { test_i16f32, i16 , f32 }
185
+ test_impl_from ! { test_i16f64, i16 , f64 }
186
+ test_impl_from ! { test_i32f64, i32 , f64 }
187
+
188
+ // Unsigned -> Float
189
+ test_impl_from ! { test_u8f32, u8 , f32 }
190
+ test_impl_from ! { test_u8f64, u8 , f64 }
191
+ test_impl_from ! { test_u16f32, u16 , f32 }
192
+ test_impl_from ! { test_u16f64, u16 , f64 }
193
+ test_impl_from ! { test_u32f64, u32 , f64 }
194
+
195
+ // Float -> Float
196
+ #[ test]
197
+ fn test_f32f64 ( ) {
198
+ use core:: f32;
199
+
200
+ let max: f64 = f32:: MAX . into ( ) ;
201
+ assert_eq ! ( max as f32 , f32 :: MAX ) ;
202
+ assert ! ( max. is_normal( ) ) ;
203
+
204
+ let min: f64 = f32:: MIN . into ( ) ;
205
+ assert_eq ! ( min as f32 , f32 :: MIN ) ;
206
+ assert ! ( min. is_normal( ) ) ;
207
+
208
+ let min_positive: f64 = f32:: MIN_POSITIVE . into ( ) ;
209
+ assert_eq ! ( min_positive as f32 , f32 :: MIN_POSITIVE ) ;
210
+ assert ! ( min_positive. is_normal( ) ) ;
211
+
212
+ let epsilon: f64 = f32:: EPSILON . into ( ) ;
213
+ assert_eq ! ( epsilon as f32 , f32 :: EPSILON ) ;
214
+ assert ! ( epsilon. is_normal( ) ) ;
215
+
216
+ let zero: f64 = ( 0.0f32 ) . into ( ) ;
217
+ assert_eq ! ( zero as f32 , 0.0f32 ) ;
218
+ assert ! ( zero. is_sign_positive( ) ) ;
219
+
220
+ let neg_zero: f64 = ( -0.0f32 ) . into ( ) ;
221
+ assert_eq ! ( neg_zero as f32 , -0.0f32 ) ;
222
+ assert ! ( neg_zero. is_sign_negative( ) ) ;
223
+
224
+ let infinity: f64 = f32:: INFINITY . into ( ) ;
225
+ assert_eq ! ( infinity as f32 , f32 :: INFINITY ) ;
226
+ assert ! ( infinity. is_infinite( ) ) ;
227
+ assert ! ( infinity. is_sign_positive( ) ) ;
228
+
229
+ let neg_infinity: f64 = f32:: NEG_INFINITY . into ( ) ;
230
+ assert_eq ! ( neg_infinity as f32 , f32 :: NEG_INFINITY ) ;
231
+ assert ! ( neg_infinity. is_infinite( ) ) ;
232
+ assert ! ( neg_infinity. is_sign_negative( ) ) ;
233
+
234
+ let nan: f64 = f32:: NAN . into ( ) ;
235
+ assert ! ( nan. is_nan( ) ) ;
236
+ }
180
237
}
0 commit comments