forked from boostorg/integer
Just use asserts, omg.
This commit is contained in:
@ -341,8 +341,7 @@ install:
|
||||
script:
|
||||
- |-
|
||||
echo "using $TOOLSET : : $COMPILER : <cxxflags>-std=$CXXSTD ;" > ~/user-config.jam
|
||||
- (cd libs/config/test && ../../../b2 config_info_travis_install toolset=$TOOLSET && ./config_info_travis)
|
||||
- (cd libs/integer/test && ../../../b2 libs/integer/test toolset=$TOOLSET)
|
||||
- ./b2 libs/integer/test toolset=$TOOLSET
|
||||
|
||||
notifications:
|
||||
email:
|
||||
|
@ -3,8 +3,6 @@
|
||||
#~ (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
import testing ;
|
||||
import modules ;
|
||||
import path ;
|
||||
|
||||
project : requirements <warnings>all <toolset>gcc:<cxxflags>-Wextra ;
|
||||
|
||||
@ -18,8 +16,8 @@ test-suite integer
|
||||
[ run integer_mask_test.cpp ]
|
||||
[ run static_log2_test.cpp ]
|
||||
[ run static_min_max_test.cpp ]
|
||||
[ run extended_euclidean_test.cpp ../../test/build//boost_unit_test_framework ]
|
||||
[ run mod_inverse_test.cpp ../../test/build//boost_unit_test_framework ]
|
||||
[ run extended_euclidean_test.cpp ]
|
||||
[ run mod_inverse_test.cpp ]
|
||||
[ compile integer_traits_include_test.cpp ]
|
||||
[ compile integer_include_test.cpp ]
|
||||
[ compile integer_mask_include_test.cpp ]
|
||||
|
@ -4,8 +4,8 @@
|
||||
* Boost Software License, Version 1.0. (See accompanying file
|
||||
* LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#define BOOST_TEST_MODULE extended_euclidean_test
|
||||
#include <boost/test/included/unit_test.hpp>
|
||||
#include <cassert>
|
||||
#include <boost/type_index.hpp>
|
||||
#include <boost/multiprecision/cpp_int.hpp>
|
||||
#include <boost/integer/common_factor.hpp>
|
||||
#include <boost/integer/extended_euclidean.hpp>
|
||||
@ -30,18 +30,20 @@ void test_extended_euclidean()
|
||||
int256_t gcdmn = gcd(m, n);
|
||||
int256_t x = u.x;
|
||||
int256_t y = u.y;
|
||||
BOOST_CHECK_EQUAL(u.gcd, gcdmn);
|
||||
BOOST_CHECK_EQUAL(m*x + n*y, gcdmn);
|
||||
assert(u.gcd == gcdmn);
|
||||
assert(m*x + n*y == gcdmn);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(extended_euclidean_test)
|
||||
int main()
|
||||
{
|
||||
test_extended_euclidean<int16_t>();
|
||||
test_extended_euclidean<int32_t>();
|
||||
test_extended_euclidean<int64_t>();
|
||||
test_extended_euclidean<int128_t>();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -4,8 +4,8 @@
|
||||
* Boost Software License, Version 1.0. (See accompanying file
|
||||
* LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#define BOOST_TEST_MODULE mod_inverse_test
|
||||
#include <boost/test/included/unit_test.hpp>
|
||||
#include <cassert>
|
||||
#include <boost/type_index.hpp>
|
||||
#include <boost/multiprecision/cpp_int.hpp>
|
||||
#include <boost/integer/common_factor.hpp>
|
||||
#include <boost/integer/mod_inverse.hpp>
|
||||
@ -34,26 +34,28 @@ void test_mod_inverse()
|
||||
// Should fail if gcd(a, mod) != 1:
|
||||
if (gcdam > 1)
|
||||
{
|
||||
BOOST_CHECK(!inv_a);
|
||||
assert(!inv_a);
|
||||
}
|
||||
else
|
||||
{
|
||||
BOOST_CHECK(inv_a.value() > 0);
|
||||
assert(inv_a.value() > 0);
|
||||
// Cast to a bigger type so the multiplication won't overflow.
|
||||
int256_t a_inv = inv_a.value();
|
||||
int256_t big_a = a;
|
||||
int256_t m = modulus;
|
||||
int256_t outta_be_one = (a_inv*big_a) % m;
|
||||
BOOST_CHECK_EQUAL(outta_be_one, 1);
|
||||
assert(outta_be_one == 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(mod_inverse_test)
|
||||
int main()
|
||||
{
|
||||
test_mod_inverse<int16_t>();
|
||||
test_mod_inverse<int32_t>();
|
||||
test_mod_inverse<int64_t>();
|
||||
test_mod_inverse<int128_t>();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user