From 4e5adc158e58021111af2df43e631e6c378eb237 Mon Sep 17 00:00:00 2001 From: Matt Borland Date: Thu, 26 Feb 2026 14:31:31 -0500 Subject: [PATCH 1/3] Add bit test --- module/Jamfile | 1 + test/test_bit.cpp | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/module/Jamfile b/module/Jamfile index 68463c18..085975ea 100644 --- a/module/Jamfile +++ b/module/Jamfile @@ -27,3 +27,4 @@ project obj int128 : int128.cxx : msvc:-interface ; run quick_test.cpp int128 : : : int128 ; +run ../test/test_bit.cpp int128 : : : int128 ; diff --git a/test/test_bit.cpp b/test/test_bit.cpp index 743c3522..54a42b48 100644 --- a/test/test_bit.cpp +++ b/test/test_bit.cpp @@ -2,10 +2,19 @@ // Distributed under the Boost Software License, Version 1.0. // https://www.boost.org/LICENSE_1_0.txt +#include + +#ifndef BOOST_INT128_BUILD_MODULE + #include #include #include -#include + +#else + +import boost.int128; + +#endif void test_has_single_bit() { From 54ef382c6730842e0fd2b436c9e589f039c0f217 Mon Sep 17 00:00:00 2001 From: Matt Borland Date: Thu, 26 Feb 2026 14:31:47 -0500 Subject: [PATCH 2/3] Test and fix export of div --- include/boost/int128/cstdlib.hpp | 8 ++++---- module/Jamfile | 1 + test/test_div.cpp | 29 ++++++++++++++++++++--------- 3 files changed, 25 insertions(+), 13 deletions(-) diff --git a/include/boost/int128/cstdlib.hpp b/include/boost/int128/cstdlib.hpp index 87c71994..228ecd9c 100644 --- a/include/boost/int128/cstdlib.hpp +++ b/include/boost/int128/cstdlib.hpp @@ -10,19 +10,19 @@ namespace boost { namespace int128 { -struct u128div_t +BOOST_INT128_EXPORT struct u128div_t { uint128_t quot; uint128_t rem; }; -struct i128div_t +BOOST_INT128_EXPORT struct i128div_t { int128_t quot; int128_t rem; }; -constexpr u128div_t div(const uint128_t x, const uint128_t y) noexcept +BOOST_INT128_EXPORT constexpr u128div_t div(const uint128_t x, const uint128_t y) noexcept { if (BOOST_INT128_UNLIKELY(x == 0U || y == 0U)) { @@ -54,7 +54,7 @@ constexpr u128div_t div(const uint128_t x, const uint128_t y) noexcept } } -constexpr i128div_t div(const int128_t x, const int128_t y) noexcept +BOOST_INT128_EXPORT constexpr i128div_t div(const int128_t x, const int128_t y) noexcept { if (BOOST_INT128_UNLIKELY(x == 0 || y == 0)) { diff --git a/module/Jamfile b/module/Jamfile index 085975ea..bddddc77 100644 --- a/module/Jamfile +++ b/module/Jamfile @@ -28,3 +28,4 @@ obj int128 : int128.cxx : msvc:-interface ; run quick_test.cpp int128 : : : int128 ; run ../test/test_bit.cpp int128 : : : int128 ; +run ../test/test_div.cpp int128 : : : int128 ; diff --git a/test/test_div.cpp b/test/test_div.cpp index dd84a0ca..519d050c 100644 --- a/test/test_div.cpp +++ b/test/test_div.cpp @@ -2,7 +2,18 @@ // Distributed under the Boost Software License, Version 1.0. // https://www.boost.org/LICENSE_1_0.txt -#include +#ifndef BOOST_INT128_BUILD_MODULE + +#include +#include +#include + +#else + +import boost.int128; + +#endif + #include #include @@ -48,22 +59,22 @@ void test_unsigned_div() BOOST_INT128_UNREACHABLE; // LCOV_EXCL_LINE } - const auto div_res {div(lhs, rhs)}; + const auto div_res {boost::int128::div(lhs, rhs)}; BOOST_TEST_EQ(div_res.quot, lhs / rhs); BOOST_TEST_EQ(div_res.rem, lhs % rhs); - const auto inv_div_res {div(rhs, lhs)}; + const auto inv_div_res {boost::int128::div(rhs, lhs)}; BOOST_TEST_EQ(inv_div_res.quot, rhs / lhs); BOOST_TEST_EQ(inv_div_res.rem, rhs % lhs); } uint128_t lhs {dist(rng), dist(rng)}; uint128_t zero {dist(rng) * 0U, dist(rng) * 0U}; - const auto lhs_num {div(lhs, zero)}; + const auto lhs_num {boost::int128::div(lhs, zero)}; BOOST_TEST_EQ(lhs_num.quot, 0U); BOOST_TEST_EQ(lhs_num.rem, 0U); - const auto lhs_denom {div(zero, lhs)}; + const auto lhs_denom {boost::int128::div(zero, lhs)}; BOOST_TEST_EQ(lhs_denom.quot, 0U); BOOST_TEST_EQ(lhs_denom.rem, 0U); } @@ -98,22 +109,22 @@ void test_signed_div() BOOST_INT128_UNREACHABLE; // LCOV_EXCL_LINE } - const auto div_res {div(lhs, rhs)}; + const auto div_res {boost::int128::div(lhs, rhs)}; BOOST_TEST_EQ(div_res.quot, lhs / rhs); BOOST_TEST_EQ(div_res.rem, lhs % rhs); - const auto inv_div_res {div(rhs, lhs)}; + const auto inv_div_res {boost::int128::div(rhs, lhs)}; BOOST_TEST_EQ(inv_div_res.quot, rhs / lhs); BOOST_TEST_EQ(inv_div_res.rem, rhs % lhs); } int128_t lhs {idist(rng), dist(rng)}; int128_t zero {idist(rng) * 0, dist(rng) * 0U}; - const auto lhs_num {div(lhs, zero)}; + const auto lhs_num {boost::int128::div(lhs, zero)}; BOOST_TEST_EQ(lhs_num.quot, 0); BOOST_TEST_EQ(lhs_num.rem, 0); - const auto lhs_denom {div(zero, lhs)}; + const auto lhs_denom {boost::int128::div(zero, lhs)}; BOOST_TEST_EQ(lhs_denom.quot, 0); BOOST_TEST_EQ(lhs_denom.rem, 0); } From 8cbbbc67511b2ebc76496e770f9bc54b68d26e54 Mon Sep 17 00:00:00 2001 From: Matt Borland Date: Mon, 2 Mar 2026 08:28:07 -0500 Subject: [PATCH 3/3] Add additional module tests --- module/Jamfile | 7 +++++++ test/test_gcd_lcm.cpp | 10 ++++++++++ test/test_i128.cpp | 9 +++++++++ test/test_i128_no_sign_conv.cpp | 10 ++++++++++ test/test_limits_i128.cpp | 9 +++++++++ test/test_limits_u128.cpp | 9 +++++++++ test/test_literals.cpp | 9 +++++++++ test/test_midpoint.cpp | 9 +++++++++ 8 files changed, 72 insertions(+) diff --git a/module/Jamfile b/module/Jamfile index bddddc77..0cdbc520 100644 --- a/module/Jamfile +++ b/module/Jamfile @@ -29,3 +29,10 @@ obj int128 : int128.cxx : msvc:-interface ; run quick_test.cpp int128 : : : int128 ; run ../test/test_bit.cpp int128 : : : int128 ; run ../test/test_div.cpp int128 : : : int128 ; +run ../test/test_gcd_lcm.cpp int128 : : : int128 ; +run ../test/test_i128.cpp int128 : : : int128 ; +run ../test/test_i128_no_sign_conv.cpp int128 : : : int128 ; +run ../test/test_limits_i128.cpp : : : int128 ; +run ../test/test_limits_u128.cpp : : : int128 ; +run ../test/test_literals.cpp : : : int128 ; +run ../test/test_midpoint.cpp : : : int128 ; diff --git a/test/test_gcd_lcm.cpp b/test/test_gcd_lcm.cpp index 4b8e1763..7d645c4c 100644 --- a/test/test_gcd_lcm.cpp +++ b/test/test_gcd_lcm.cpp @@ -2,7 +2,17 @@ // Distributed under the Boost Software License, Version 1.0. // https://www.boost.org/LICENSE_1_0.txt + +#ifndef BOOST_INT128_BUILD_MODULE + #include + +#else + +import boost.int128; + +#endif + #include #include diff --git a/test/test_i128.cpp b/test/test_i128.cpp index a898fdf8..d52c2e59 100644 --- a/test/test_i128.cpp +++ b/test/test_i128.cpp @@ -6,9 +6,18 @@ # define BOOST_INT128_ALLOW_SIGN_CONVERSION #endif +#ifndef BOOST_INT128_BUILD_MODULE + #include #include #include + +#else + +import boost.int128; + +#endif + #include #include #include diff --git a/test/test_i128_no_sign_conv.cpp b/test/test_i128_no_sign_conv.cpp index c5bfe7f7..ba2a289e 100644 --- a/test/test_i128_no_sign_conv.cpp +++ b/test/test_i128_no_sign_conv.cpp @@ -2,8 +2,18 @@ // Distributed under the Boost Software License, Version 1.0. // https://www.boost.org/LICENSE_1_0.txt +#ifndef BOOST_INT128_BUILD_MODULE + #include #include +#include + +#else + +import boost.int128; + +#endif + #include #include #include diff --git a/test/test_limits_i128.cpp b/test/test_limits_i128.cpp index c266bdcc..95d3ffaf 100644 --- a/test/test_limits_i128.cpp +++ b/test/test_limits_i128.cpp @@ -2,7 +2,16 @@ // Distributed under the Boost Software License, Version 1.0. // https://www.boost.org/LICENSE_1_0.txt +#ifndef BOOST_INT128_BUILD_MODULE + #include + +#else + +import boost.int128; + +#endif + #include #include diff --git a/test/test_limits_u128.cpp b/test/test_limits_u128.cpp index bac9c810..1dd0ab7a 100644 --- a/test/test_limits_u128.cpp +++ b/test/test_limits_u128.cpp @@ -2,7 +2,16 @@ // Distributed under the Boost Software License, Version 1.0. // https://www.boost.org/LICENSE_1_0.txt +#ifndef BOOST_INT128_BUILD_MODULE + #include + +#else + +import boost.int128; + +#endif + #include #include diff --git a/test/test_literals.cpp b/test/test_literals.cpp index a036ab61..37c94081 100644 --- a/test/test_literals.cpp +++ b/test/test_literals.cpp @@ -2,9 +2,18 @@ // Distributed under the Boost Software License, Version 1.0. // https://www.boost.org/LICENSE_1_0.txt +#ifndef BOOST_INT128_BUILD_MODULE + #include #include #include + +#else + +import boost.int128; + +#endif + #include #include diff --git a/test/test_midpoint.cpp b/test/test_midpoint.cpp index e1d9ffa8..1a84dbe0 100644 --- a/test/test_midpoint.cpp +++ b/test/test_midpoint.cpp @@ -2,7 +2,16 @@ // Distributed under the Boost Software License, Version 1.0. // https://www.boost.org/LICENSE_1_0.txt +#ifndef BOOST_INT128_BUILD_MODULE + #include + +#else + +import boost.int128; + +#endif + #include #include