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));
28 fn shortest_sanity_test() {
29 f64_shortest_sanity_test(format_shortest);
30 f32_shortest_sanity_test(format_shortest);
31 more_shortest_sanity_test(format_shortest);
35 fn exact_sanity_test() {
36 // This test ends up running what I can only assume is some corner-ish case
37 // of the `exp2` library function, defined in whatever C runtime we're
38 // using. In VS 2013 this function apparently had a bug as this test fails
39 // when linked, but with VS 2015 the bug appears fixed as the test runs just
42 // The bug seems to be a difference in return value of `exp2(-1057)`, where
43 // in VS 2013 it returns a double with the bit pattern 0x2 and in VS 2015 it
46 // For now just ignore this test entirely on MSVC as it's tested elsewhere
47 // anyway and we're not super interested in testing each platform's exp2
49 if !cfg!(target_env = "msvc") {
50 f64_exact_sanity_test(format_exact);
52 f32_exact_sanity_test(format_exact);
56 fn test_to_shortest_str() {
57 to_shortest_str_test(format_shortest);
61 fn test_to_shortest_exp_str() {
62 to_shortest_exp_str_test(format_shortest);
66 fn test_to_exact_exp_str() {
67 to_exact_exp_str_test(format_exact);
71 fn test_to_exact_fixed_str() {
72 to_exact_fixed_str_test(format_exact);