File: d2s_intrinsics_test.cpp

package info (click to toggle)
boost1.83 1.83.0-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 545,632 kB
  • sloc: cpp: 3,857,086; xml: 125,552; ansic: 34,414; python: 25,887; asm: 5,276; sh: 4,799; ada: 1,681; makefile: 1,629; perl: 1,212; pascal: 1,139; sql: 810; yacc: 478; ruby: 102; lisp: 24; csh: 6
file content (58 lines) | stat: -rw-r--r-- 1,614 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// Copyright 2018 Ulf Adams
//
// The contents of this file may be used under the terms of the Apache License,
// Version 2.0.
//
//    (See accompanying file LICENSE-Apache or copy at
//     http://www.apache.org/licenses/LICENSE-2.0)
//
// Alternatively, the contents of this file may be used under the terms of
// the Boost Software License, Version 1.0.
//    (See accompanying file LICENSE-Boost or copy at
//     https://www.boost.org/LICENSE_1_0.txt)
//
// Unless required by applicable law or agreed to in writing, this software
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied.

/*
    This is a derivative work
*/

#include <boost/json/detail/ryu/detail/d2s_intrinsics.hpp>
#include "gtest.hpp"
#include <math.h>

namespace boost {
namespace json {
namespace detail {

namespace ryu {
namespace detail {

TEST(D2sIntrinsicsTest, mod1e9) {
  ASSERT_EQ(0, mod1e9(0));
  ASSERT_EQ(1, mod1e9(1));
  ASSERT_EQ(2, mod1e9(2));
  ASSERT_EQ(10, mod1e9(10));
  ASSERT_EQ(100, mod1e9(100));
  ASSERT_EQ(1000, mod1e9(1000));
  ASSERT_EQ(10000, mod1e9(10000));
  ASSERT_EQ(100000, mod1e9(100000));
  ASSERT_EQ(1000000, mod1e9(1000000));
  ASSERT_EQ(10000000, mod1e9(10000000));
  ASSERT_EQ(100000000, mod1e9(100000000));
  ASSERT_EQ(0, mod1e9(1000000000));
  ASSERT_EQ(0, mod1e9(2000000000));
  ASSERT_EQ(1, mod1e9(1000000001));
  ASSERT_EQ(1234, mod1e9(1000001234));
  ASSERT_EQ(123456789, mod1e9(12345123456789ull));
  ASSERT_EQ(123456789, mod1e9(123456789123456789ull));
}

} // detail
} // ryu

} // detail
} // namespace json
} // namespace boost