1 // Translated from C to Rust. The original C code can be found at
2 // https://github.com/ulfjack/ryu and carries the following license:
3 //
4 // Copyright 2018 Ulf Adams
5 //
6 // The contents of this file may be used under the terms of the Apache License,
7 // Version 2.0.
8 //
9 // (See accompanying file LICENSE-Apache or copy at
10 // http://www.apache.org/licenses/LICENSE-2.0)
11 //
12 // Alternatively, the contents of this file may be used under the terms of
13 // the Boost Software License, Version 1.0.
14 // (See accompanying file LICENSE-Boost or copy at
15 // https://www.boost.org/LICENSE_1_0.txt)
16 //
17 // Unless required by applicable law or agreed to in writing, this software
18 // is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19 // KIND, either express or implied.
20
21 #![allow(dead_code)]
22
23 extern crate core;
24
25 #[path = "../src/common.rs"]
26 mod common;
27
28 #[path = "../src/d2s_full_table.rs"]
29 mod d2s_full_table;
30
31 #[path = "../src/d2s_intrinsics.rs"]
32 mod d2s_intrinsics;
33
34 #[path = "../src/d2s_small_table.rs"]
35 mod d2s_small_table;
36
37 use d2s_full_table::*;
38 use d2s_small_table::*;
39
40 #[test]
test_compute_pow5()41 fn test_compute_pow5() {
42 for (i, entry) in DOUBLE_POW5_SPLIT.iter().enumerate() {
43 assert_eq!(*entry, unsafe { compute_pow5(i as u32) }, "entry {}", i);
44 }
45 }
46
47 #[test]
test_compute_inv_pow5()48 fn test_compute_inv_pow5() {
49 for (i, entry) in DOUBLE_POW5_INV_SPLIT.iter().enumerate() {
50 assert_eq!(*entry, unsafe { compute_inv_pow5(i as u32) }, "entry {}", i);
51 }
52 }
53