1 | #[cfg (not(all(any(target_arch = "x86" , target_arch = "x86_64" ), feature = "simd" )))] |
2 | mod simd_core; |
3 | #[cfg (not(all(any(target_arch = "x86" , target_arch = "x86_64" ), feature = "simd" )))] |
4 | pub use simd_core::*; |
5 | |
6 | #[cfg (all(any(target_arch = "x86" , target_arch = "x86_64" ), feature = "simd" ))] |
7 | mod simd_x86; |
8 | #[cfg (all(any(target_arch = "x86" , target_arch = "x86_64" ), feature = "simd" ))] |
9 | pub use simd_x86::*; |
10 | |
11 | mod float; |
12 | pub use float::*; |
13 | |
14 | #[cfg (test)] |
15 | mod tests { |
16 | use super::*; |
17 | |
18 | #[test ] |
19 | fn platform_ceil_test() { |
20 | use core::mem::transmute; |
21 | let mut y = 3.0; |
22 | while y < 9.0 { |
23 | assert_eq!(ceil(y), f32::ceil(y)); |
24 | y = unsafe { transmute::<u32, f32>(transmute::<f32, u32>(y) + 1) }; |
25 | } |
26 | |
27 | assert_eq!(ceil(-1.5), -1.0); |
28 | assert_eq!(ceil(-1.0), -1.0); |
29 | assert_eq!(ceil(-0.5), 0.0); |
30 | assert_eq!(ceil(0.0), 0.0); |
31 | assert_eq!(ceil(0.5), 1.0); |
32 | assert_eq!(ceil(1.0), 1.0); |
33 | assert_eq!(ceil(1.5), 2.0); |
34 | } |
35 | |
36 | #[test ] |
37 | fn platform_floor_test() { |
38 | use core::mem::transmute; |
39 | let mut y = -3.0; |
40 | while y > -9.0 { |
41 | assert_eq!(ceil(y), f32::ceil(y)); |
42 | y = unsafe { transmute::<u32, f32>(transmute::<f32, u32>(y) + 1) }; |
43 | } |
44 | |
45 | assert_eq!(floor(-1.5), -2.0); |
46 | assert_eq!(floor(-1.0), -1.0); |
47 | assert_eq!(floor(-0.5), -1.0); |
48 | assert_eq!(floor(0.0), 0.0); |
49 | assert_eq!(floor(0.5), 0.0); |
50 | assert_eq!(floor(1.0), 1.0); |
51 | assert_eq!(floor(1.5), 1.0); |
52 | } |
53 | |
54 | #[test ] |
55 | fn platform_fract_test() { |
56 | assert_eq!(fract(-1.5), -0.5); |
57 | assert_eq!(fract(-1.0), 0.0); |
58 | assert_eq!(fract(-0.5), -0.5); |
59 | assert_eq!(fract(0.0), 0.0); |
60 | assert_eq!(fract(0.5), 0.5); |
61 | assert_eq!(fract(1.0), 0.0); |
62 | assert_eq!(fract(1.5), 0.5); |
63 | } |
64 | |
65 | #[test ] |
66 | fn platform_trunc_test() { |
67 | assert_eq!(trunc(-1.5), -1.0); |
68 | assert_eq!(trunc(-1.0), -1.0); |
69 | assert_eq!(trunc(-0.5), 0.0); |
70 | assert_eq!(trunc(0.0), 0.0); |
71 | assert_eq!(trunc(0.5), 0.0); |
72 | assert_eq!(trunc(1.0), 1.0); |
73 | assert_eq!(trunc(1.5), 1.0); |
74 | } |
75 | } |
76 | |