]> git.proxmox.com Git - rustc.git/blame - src/libcoretest/num/flt2dec/strategy/dragon.rs
New upstream version 1.17.0+dfsg2
[rustc.git] / src / libcoretest / num / flt2dec / strategy / dragon.rs
CommitLineData
d9579d0f
AL
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.
4//
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.
10
11use std::prelude::v1::*;
d9579d0f 12use super::super::*;
b039eaaf 13use core::num::bignum::Big32x40 as Big;
d9579d0f
AL
14use core::num::flt2dec::strategy::dragon::*;
15
16#[test]
17fn test_mul_pow10() {
18 let mut prevpow10 = Big::from_small(1);
19 for i in 1..340 {
20 let mut curpow10 = Big::from_small(1);
21 mul_pow10(&mut curpow10, i);
22 assert_eq!(curpow10, *prevpow10.clone().mul_small(10));
23 prevpow10 = curpow10;
24 }
25}
26
27#[test]
28fn shortest_sanity_test() {
29 f64_shortest_sanity_test(format_shortest);
30 f32_shortest_sanity_test(format_shortest);
31 more_shortest_sanity_test(format_shortest);
32}
33
34#[test]
35fn exact_sanity_test() {
e9174d1e
SL
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
40 // fine.
41 //
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
44 // returns 0x20000.
45 //
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
48 // implementation.
49 if !cfg!(target_env = "msvc") {
50 f64_exact_sanity_test(format_exact);
51 }
d9579d0f
AL
52 f32_exact_sanity_test(format_exact);
53}
54
d9579d0f
AL
55#[test]
56fn test_to_shortest_str() {
57 to_shortest_str_test(format_shortest);
58}
59
60#[test]
61fn test_to_shortest_exp_str() {
62 to_shortest_exp_str_test(format_shortest);
63}
64
65#[test]
66fn test_to_exact_exp_str() {
67 to_exact_exp_str_test(format_exact);
68}
69
70#[test]
71fn test_to_exact_fixed_str() {
72 to_exact_fixed_str_test(format_exact);
73}
74