]> git.lizzy.rs Git - rust.git/blob - src/libcore/tests/num/flt2dec/strategy/grisu.rs
libcore: ignore tests in Miri instead of removing them entirely
[rust.git] / src / libcore / tests / num / flt2dec / strategy / grisu.rs
1 use super::super::*;
2 use core::num::flt2dec::strategy::grisu::*;
3
4 #[test]
5 fn test_cached_power() {
6     assert_eq!(CACHED_POW10.first().unwrap().1, CACHED_POW10_FIRST_E);
7     assert_eq!(CACHED_POW10.last().unwrap().1, CACHED_POW10_LAST_E);
8
9     for e in -1137..961 { // full range for f64
10         let low = ALPHA - e - 64;
11         let high = GAMMA - e - 64;
12         let (_k, cached) = cached_power(low, high);
13         assert!(low <= cached.e && cached.e <= high,
14                 "cached_power({}, {}) = {:?} is incorrect", low, high, cached);
15     }
16 }
17
18 #[test]
19 fn test_max_pow10_no_more_than() {
20     let mut prevtenk = 1;
21     for k in 1..10 {
22         let tenk = prevtenk * 10;
23         assert_eq!(max_pow10_no_more_than(tenk - 1), (k - 1, prevtenk));
24         assert_eq!(max_pow10_no_more_than(tenk), (k, tenk));
25         prevtenk = tenk;
26     }
27 }
28
29
30 #[cfg_attr(all(target_arch = "wasm32", target_os = "emscripten"), ignore)] // issue 42630
31 #[test]
32 fn shortest_sanity_test() {
33     f64_shortest_sanity_test(format_shortest);
34     f32_shortest_sanity_test(format_shortest);
35     more_shortest_sanity_test(format_shortest);
36 }
37
38 #[test]
39 #[cfg_attr(miri, ignore)] // Miri is too slow
40 fn exact_sanity_test() {
41     // See comments in dragon.rs's exact_sanity_test for why this test is
42     // ignored on MSVC
43     if !cfg!(target_env = "msvc") {
44         f64_exact_sanity_test(format_exact);
45     }
46     f32_exact_sanity_test(format_exact);
47 }
48
49 #[test]
50 fn test_to_shortest_str() {
51     to_shortest_str_test(format_shortest);
52 }
53
54 #[test]
55 fn test_to_shortest_exp_str() {
56     to_shortest_exp_str_test(format_shortest);
57 }
58
59 #[test]
60 fn test_to_exact_exp_str() {
61     to_exact_exp_str_test(format_exact);
62 }
63
64 #[test]
65 fn test_to_exact_fixed_str() {
66     to_exact_fixed_str_test(format_exact);
67 }