2 use core::num::flt2dec::strategy::grisu::*;
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);
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);
19 fn test_max_pow10_no_more_than() {
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));
30 #[cfg_attr(all(target_arch = "wasm32", target_os = "emscripten"), ignore)] // issue 42630
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);
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
43 if !cfg!(target_env = "msvc") {
44 f64_exact_sanity_test(format_exact);
46 f32_exact_sanity_test(format_exact);
50 fn test_to_shortest_str() {
51 to_shortest_str_test(format_shortest);
55 fn test_to_shortest_exp_str() {
56 to_shortest_exp_str_test(format_shortest);
60 fn test_to_exact_exp_str() {
61 to_exact_exp_str_test(format_exact);
65 fn test_to_exact_fixed_str() {
66 to_exact_fixed_str_test(format_exact);