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 #[path = "../src/common.rs"]
24 mod common;
25
26 #[path = "../src/d2s_full_table.rs"]
27 mod d2s_full_table;
28
29 #[path = "../src/d2s_intrinsics.rs"]
30 mod d2s_intrinsics;
31
32 #[path = "../src/d2s_small_table.rs"]
33 mod d2s_small_table;
34
35 use d2s_full_table::*;
36 use d2s_small_table::*;
37
38 #[test]
test_compute_pow5()39 fn test_compute_pow5() {
40 for (i, entry) in DOUBLE_POW5_SPLIT.iter().enumerate() {
41 assert_eq!(*entry, unsafe { compute_pow5(i as u32) }, "entry {}", i);
42 }
43 }
44
45 #[test]
test_compute_inv_pow5()46 fn test_compute_inv_pow5() {
47 for (i, entry) in DOUBLE_POW5_INV_SPLIT[..292].iter().enumerate() {
48 assert_eq!(*entry, unsafe { compute_inv_pow5(i as u32) }, "entry {}", i);
49 }
50 }
51