1 // Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 use std::prelude::v1::*;
13 use core::num::bignum::Big32x40 as Big;
14 use core::num::flt2dec::strategy::dragon::*;
18 let mut prevpow10 = Big::from_small(1);
20 let mut curpow10 = Big::from_small(1);
21 mul_pow10(&mut curpow10, i);
22 assert_eq!(curpow10, *prevpow10.clone().mul_small(10));
27 #[cfg_attr(all(target_arch = "wasm32", target_os = "emscripten"), ignore)] // issue 42630
29 fn shortest_sanity_test() {
30 f64_shortest_sanity_test(format_shortest);
31 f32_shortest_sanity_test(format_shortest);
32 more_shortest_sanity_test(format_shortest);
36 fn exact_sanity_test() {
37 // This test ends up running what I can only assume is some corner-ish case
38 // of the `exp2` library function, defined in whatever C runtime we're
39 // using. In VS 2013 this function apparently had a bug as this test fails
40 // when linked, but with VS 2015 the bug appears fixed as the test runs just
43 // The bug seems to be a difference in return value of `exp2(-1057)`, where
44 // in VS 2013 it returns a double with the bit pattern 0x2 and in VS 2015 it
47 // For now just ignore this test entirely on MSVC as it's tested elsewhere
48 // anyway and we're not super interested in testing each platform's exp2
50 if !cfg!(target_env = "msvc") {
51 f64_exact_sanity_test(format_exact);
53 f32_exact_sanity_test(format_exact);
57 fn test_to_shortest_str() {
58 to_shortest_str_test(format_shortest);
62 fn test_to_shortest_exp_str() {
63 to_shortest_exp_str_test(format_shortest);
67 fn test_to_exact_exp_str() {
68 to_exact_exp_str_test(format_exact);
72 fn test_to_exact_fixed_str() {
73 to_exact_fixed_str_test(format_exact);