]> git.lizzy.rs Git - rust.git/blob - src/libcore/tests/num/flt2dec/strategy/dragon.rs
0c545b4d88714f3d34f50502fc6720fa611f8657
[rust.git] / src / libcore / tests / num / flt2dec / strategy / dragon.rs
1 use super::super::*;
2 use core::num::bignum::Big32x40 as Big;
3 use core::num::flt2dec::strategy::dragon::*;
4
5 #[test]
6 fn test_mul_pow10() {
7     let mut prevpow10 = Big::from_small(1);
8     for i in 1..340 {
9         let mut curpow10 = Big::from_small(1);
10         mul_pow10(&mut curpow10, i);
11         assert_eq!(curpow10, *prevpow10.clone().mul_small(10));
12         prevpow10 = curpow10;
13     }
14 }
15
16 #[cfg_attr(all(target_arch = "wasm32", target_os = "emscripten"), ignore)] // issue 42630
17 #[test]
18 fn shortest_sanity_test() {
19     f64_shortest_sanity_test(format_shortest);
20     f32_shortest_sanity_test(format_shortest);
21     more_shortest_sanity_test(format_shortest);
22 }
23
24 #[test]
25 #[cfg(not(miri))] // Miri is too slow
26 fn exact_sanity_test() {
27     // This test ends up running what I can only assume is some corner-ish case
28     // of the `exp2` library function, defined in whatever C runtime we're
29     // using. In VS 2013 this function apparently had a bug as this test fails
30     // when linked, but with VS 2015 the bug appears fixed as the test runs just
31     // fine.
32     //
33     // The bug seems to be a difference in return value of `exp2(-1057)`, where
34     // in VS 2013 it returns a double with the bit pattern 0x2 and in VS 2015 it
35     // returns 0x20000.
36     //
37     // For now just ignore this test entirely on MSVC as it's tested elsewhere
38     // anyway and we're not super interested in testing each platform's exp2
39     // implementation.
40     if !cfg!(target_env = "msvc") {
41         f64_exact_sanity_test(format_exact);
42     }
43     f32_exact_sanity_test(format_exact);
44 }
45
46 #[test]
47 fn test_to_shortest_str() {
48     to_shortest_str_test(format_shortest);
49 }
50
51 #[test]
52 fn test_to_shortest_exp_str() {
53     to_shortest_exp_str_test(format_shortest);
54 }
55
56 #[test]
57 fn test_to_exact_exp_str() {
58     to_exact_exp_str_test(format_exact);
59 }
60
61 #[test]
62 fn test_to_exact_fixed_str() {
63     to_exact_fixed_str_test(format_exact);
64 }