mirror of
https://github.com/boostorg/multiprecision.git
synced 2026-01-19 04:22:11 +00:00
Add standalone test-suite
This commit is contained in:
62
.github/workflows/multiprecision.yml
vendored
62
.github/workflows/multiprecision.yml
vendored
@@ -139,6 +139,68 @@ jobs:
|
||||
- name: Test
|
||||
run: ../../../b2 -j2 toolset=$TOOLSET ${{ matrix.suite }} define=CI_SUPPRESS_KNOWN_ISSUES
|
||||
working-directory: ../boost-root/libs/multiprecision/test
|
||||
ubuntu-focal-standalone-tests:
|
||||
runs-on: ubuntu-20.04
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
compiler: [ g++-11 ]
|
||||
standard: [ c++11, c++14, c++17, c++20 ]
|
||||
suite: [ standalone ]
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: '0'
|
||||
- name: Set TOOLSET
|
||||
run: echo ${{ matrix.compiler }} | awk '/^g/ { print "TOOLSET=gcc" } /^clang/ { print "TOOLSET=clang" }' >> $GITHUB_ENV
|
||||
- name: Add repository
|
||||
continue-on-error: true
|
||||
id: addrepo
|
||||
run: sudo apt-add-repository -y "ppa:ubuntu-toolchain-r/test"
|
||||
- name: Retry Add Repo
|
||||
continue-on-error: true
|
||||
id: retry1
|
||||
if: steps.addrepo.outcome=='failure'
|
||||
run: sudo apt-add-repository -y "ppa:ubuntu-toolchain-r/test"
|
||||
- name: Retry Add Repo 2
|
||||
continue-on-error: true
|
||||
id: retry2
|
||||
if: steps.retry1.outcome=='failure'
|
||||
run: sudo apt-add-repository -y "ppa:ubuntu-toolchain-r/test"
|
||||
- name: Install packages
|
||||
run: sudo apt install g++-11 libgmp-dev libmpfr-dev libtommath-dev
|
||||
- name: Checkout main boost
|
||||
run: git clone -b develop --depth 1 https://github.com/boostorg/boost.git ../boost-root
|
||||
- name: Update tools/boostdep
|
||||
run: git submodule update --init tools/boostdep
|
||||
working-directory: ../boost-root
|
||||
- name: Copy files
|
||||
run: cp -r $GITHUB_WORKSPACE/* libs/multiprecision
|
||||
working-directory: ../boost-root
|
||||
- name: Install deps
|
||||
run: python tools/boostdep/depinst/depinst.py multiprecision
|
||||
working-directory: ../boost-root
|
||||
- name: Bootstrap
|
||||
run: ./bootstrap.sh
|
||||
working-directory: ../boost-root
|
||||
- name: Generate headers
|
||||
run: ./b2 headers
|
||||
working-directory: ../boost-root
|
||||
- name: Generate user config
|
||||
run: 'echo "using $TOOLSET : : ${{ matrix.compiler }} : <cxxflags>-std=${{ matrix.standard }} ;" > ~/user-config.jam'
|
||||
working-directory: ../boost-root
|
||||
- name: Config info install
|
||||
run: ../../../b2 config_info_travis_install toolset=$TOOLSET
|
||||
working-directory: ../boost-root/libs/config/test
|
||||
- name: Config info
|
||||
run: ./config_info_travis
|
||||
working-directory: ../boost-root/libs/config/test
|
||||
- name: Test
|
||||
run: ../../../b2 -j2 toolset=$TOOLSET ${{ matrix.suite }} define=CI_SUPPRESS_KNOWN_ISSUES
|
||||
working-directory: ../boost-root/libs/multiprecision/test
|
||||
ubuntu-focal-ASAN:
|
||||
runs-on: ubuntu-20.04
|
||||
defaults:
|
||||
|
||||
@@ -1335,7 +1335,7 @@ inline BOOST_CXX14_CONSTEXPR T constexpr_lcm(T a, T b) noexcept
|
||||
#else
|
||||
|
||||
template <typename T>
|
||||
inline BOOST_CXX14_CONSTEXPR constexpr_gcd(T a, T b) noexcept
|
||||
inline BOOST_CXX14_CONSTEXPR T constexpr_gcd(T a, T b) noexcept
|
||||
{
|
||||
return boost::multiprecision::backends::eval_gcd(a, b);
|
||||
}
|
||||
|
||||
@@ -948,14 +948,6 @@ test-suite misc :
|
||||
[ check-target-builds ../config//has_gmp : : <build>no ]
|
||||
release # otherwise [ runtime is too slow!!
|
||||
]
|
||||
|
||||
[ run test_miller_rabin_standalone.cpp no_eh_support gmp
|
||||
: # command line
|
||||
: # input files
|
||||
: # requirements
|
||||
[ check-target-builds ../config//has_gmp : : <build>no ]
|
||||
release # otherwise [ runtime is too slow!!
|
||||
]
|
||||
|
||||
[ run test_rational_io.cpp $(TOMMATH) no_eh_support
|
||||
: # command line
|
||||
@@ -1169,6 +1161,30 @@ test-suite misc :
|
||||
[ run test_eigen_interop_mpc.cpp mpc mpfr gmp : : : release [ check-target-builds ../config//has_eigen : : <build>no ] [ check-target-builds ../config//has_mpc : : <build>no ] ]
|
||||
;
|
||||
|
||||
test-suite standalone :
|
||||
|
||||
[ run standalone_constexpr_test_cpp_int.cpp : : : [ requires cxx14_constexpr cxx17_if_constexpr ] [ check-target-builds ../config//has_is_constant_evaluated : : <build>no ] ]
|
||||
[ compile standalone_constexpr_test_float128.cpp :
|
||||
[ requires cxx14_constexpr cxx17_if_constexpr ] [ check-target-builds ../config//has_float128 : <source>quadmath : <build>no ] ]
|
||||
|
||||
[ run standalone_test_arithmetic_ab.cpp no_eh_support ]
|
||||
|
||||
[ run standalone_test_arithmetic_complex128.cpp : : : [ check-target-builds ../config//has_float128 : <source>quadmath ] ]
|
||||
[ run standalone_test_arithmetic_cpp_bin_float.cpp no_eh_support : : : <toolset>msvc:<cxxflags>-bigobj ]
|
||||
[ run standalone_test_arithmetic_cpp_dec_float.cpp no_eh_support : : : <toolset>msvc:<cxxflags>-bigobj ]
|
||||
[ run standalone_test_arithmetic_cpp_int.cpp no_eh_support : : : <toolset>msvc:<cxxflags>-bigobj ]
|
||||
[ run standalone_test_arithmetic_int512.cpp no_eh_support : : : <toolset>msvc:<cxxflags>-bigobj ]
|
||||
[ run standalone_test_arithmetic_cpp_rational.cpp no_eh_support : : : <toolset>msvc:<cxxflags>-bigobj ]
|
||||
[ run standalone_test_arithmetic_float_128.cpp quadmath no_eh_support : : : [ check-target-builds ../config//has_float128 : : <build>no ] ]
|
||||
|
||||
[ run standalone_test_miller_rabin.cpp no_eh_support gmp
|
||||
: # command line
|
||||
: # input files
|
||||
: # requirements
|
||||
[ check-target-builds ../config//has_gmp : : <build>no ]
|
||||
release # otherwise [ runtime is too slow!!
|
||||
]
|
||||
;
|
||||
|
||||
#
|
||||
# This take too long to run as a regular part of the tests:
|
||||
|
||||
104
test/standalone_constexpr_test_cpp_int.cpp
Normal file
104
test/standalone_constexpr_test_cpp_int.cpp
Normal file
@@ -0,0 +1,104 @@
|
||||
// (C) Copyright John Maddock 2019 - 2021.
|
||||
// (C) Copyright Matt Borland 2021.
|
||||
// Use, modification and distribution are subject to the
|
||||
// Boost Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include "test.hpp"
|
||||
|
||||
#define BOOST_MP_STANDALONE
|
||||
|
||||
#include "constexpr_arithmetric_test.hpp"
|
||||
#include "boost/multiprecision/cpp_int.hpp"
|
||||
|
||||
#if !defined(BOOST_MP_NO_CONSTEXPR_DETECTION) && !defined(DISABLE_TESTS)
|
||||
|
||||
template <class F, class V>
|
||||
decltype(std::declval<F>()(std::declval<V>())) non_constexpr_invoke(F f, V v)
|
||||
{
|
||||
return f(v);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef boost::multiprecision::int256_t int_backend;
|
||||
typedef boost::multiprecision::uint256_t unsigned_backend;
|
||||
|
||||
{
|
||||
constexpr int_backend a(22);
|
||||
constexpr unsigned_backend c(22);
|
||||
constexpr int_backend b = test_constexpr_add_subtract(a);
|
||||
constexpr unsigned_backend d = test_constexpr_add_subtract(c);
|
||||
|
||||
constexpr long long llv = (long long)b;
|
||||
|
||||
static_assert(b == -108);
|
||||
static_assert(d == 554);
|
||||
static_assert(llv == -108);
|
||||
|
||||
BOOST_CHECK_EQUAL(b, non_constexpr_invoke(test_constexpr_add_subtract<int_backend>, a));
|
||||
BOOST_CHECK_EQUAL(d, non_constexpr_invoke(test_constexpr_add_subtract<unsigned_backend>, c));
|
||||
}
|
||||
{
|
||||
constexpr int_backend a(22);
|
||||
constexpr unsigned_backend c(22);
|
||||
constexpr int_backend b = test_constexpr_mul_divide(a);
|
||||
constexpr unsigned_backend d = test_constexpr_mul_divide(c);
|
||||
static_assert(b == 22);
|
||||
static_assert(d == 22);
|
||||
|
||||
BOOST_CHECK_EQUAL(b, non_constexpr_invoke(test_constexpr_mul_divide<int_backend>, a));
|
||||
BOOST_CHECK_EQUAL(d, non_constexpr_invoke(test_constexpr_mul_divide<unsigned_backend>, c));
|
||||
}
|
||||
{
|
||||
constexpr int_backend a(22);
|
||||
constexpr unsigned_backend c(22);
|
||||
constexpr int_backend b = test_constexpr_bitwise(a);
|
||||
constexpr unsigned_backend d = test_constexpr_bitwise(c);
|
||||
#ifdef BOOST_HAS_INT128
|
||||
static_assert(b == 230);
|
||||
static_assert(d == 120);
|
||||
#else
|
||||
static_assert(b == 210);
|
||||
static_assert(d == 106);
|
||||
#endif
|
||||
|
||||
BOOST_CHECK_EQUAL(b, non_constexpr_invoke(test_constexpr_bitwise<int_backend>, a));
|
||||
BOOST_CHECK_EQUAL(d, non_constexpr_invoke(test_constexpr_bitwise<unsigned_backend>, c));
|
||||
}
|
||||
{
|
||||
constexpr int_backend a(22);
|
||||
constexpr unsigned_backend c(22);
|
||||
constexpr int_backend b = test_constexpr_logical(a);
|
||||
constexpr unsigned_backend d = test_constexpr_logical(c);
|
||||
#ifdef BOOST_HAS_INT128
|
||||
//static_assert(b == 95);
|
||||
//static_assert(d == 95);
|
||||
#else
|
||||
static_assert(b == 82);
|
||||
static_assert(d == 82);
|
||||
#endif
|
||||
BOOST_CHECK_EQUAL(b, non_constexpr_invoke(test_constexpr_logical<int_backend>, a));
|
||||
BOOST_CHECK_EQUAL(d, non_constexpr_invoke(test_constexpr_logical<unsigned_backend>, c));
|
||||
}
|
||||
{
|
||||
constexpr int_backend a(22);
|
||||
constexpr unsigned_backend c(22);
|
||||
constexpr int_backend b = test_constexpr_compare(a);
|
||||
constexpr unsigned_backend d = test_constexpr_compare(c);
|
||||
#ifdef BOOST_HAS_INT128
|
||||
static_assert(b == 95);
|
||||
static_assert(d == 95);
|
||||
#else
|
||||
static_assert(b == 95);
|
||||
static_assert(d == 95);
|
||||
#endif
|
||||
BOOST_CHECK_EQUAL(b, non_constexpr_invoke(test_constexpr_compare<int_backend>, a));
|
||||
BOOST_CHECK_EQUAL(d, non_constexpr_invoke(test_constexpr_compare<unsigned_backend>, c));
|
||||
}
|
||||
return boost::report_errors();
|
||||
}
|
||||
#else
|
||||
int main() {}
|
||||
#endif
|
||||
|
||||
74
test/standalone_constexpr_test_float128.cpp
Normal file
74
test/standalone_constexpr_test_float128.cpp
Normal file
@@ -0,0 +1,74 @@
|
||||
// (C) Copyright John Maddock 2019 - 2021.
|
||||
// (C) Copyright Matt Borland 2021.
|
||||
// Use, modification and distribution are subject to the
|
||||
// Boost Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#include "constexpr_arithmetric_test.hpp"
|
||||
|
||||
#define BOOST_MP_STANDALONE
|
||||
|
||||
#include <boost/multiprecision/float128.hpp>
|
||||
#include <iostream>
|
||||
|
||||
int main()
|
||||
{
|
||||
using boost::multiprecision::float128;
|
||||
|
||||
{
|
||||
constexpr float128 a(22);
|
||||
constexpr float128 b = test_constexpr_add_subtract(a);
|
||||
|
||||
constexpr __float128 f128 = (__float128)b;
|
||||
static_assert(f128 == -134.0f);
|
||||
|
||||
constexpr int i = (int)b;
|
||||
static_assert(i == -134);
|
||||
|
||||
constexpr short s = (short)b;
|
||||
static_assert(s == -134);
|
||||
}
|
||||
{
|
||||
constexpr float128 a(22);
|
||||
constexpr float128 b = test_constexpr_mul_divide(a);
|
||||
static_assert((__float128)b == 0);
|
||||
}
|
||||
{
|
||||
constexpr float128 a(22);
|
||||
constexpr float128 b = test_constexpr_compare(a);
|
||||
static_assert((__float128)b == 119);
|
||||
}
|
||||
{
|
||||
constexpr float128 a(0);
|
||||
static_assert(fpclassify(a) == FP_ZERO);
|
||||
constexpr float128 b(1);
|
||||
static_assert(fpclassify(b) == FP_NORMAL);
|
||||
constexpr float128 c(-1);
|
||||
static_assert(fpclassify(c) == FP_NORMAL);
|
||||
static_assert(abs(c) >= 0);
|
||||
static_assert(fabs(c) >= 0);
|
||||
constexpr float128 d(std::numeric_limits<float128>::epsilon());
|
||||
static_assert(fpclassify(c) == FP_NORMAL);
|
||||
constexpr float128 e((std::numeric_limits<float128>::min)());
|
||||
static_assert(fpclassify(e) == FP_NORMAL);
|
||||
constexpr float128 f((std::numeric_limits<float128>::max)());
|
||||
static_assert(fpclassify(f) == FP_NORMAL);
|
||||
constexpr float128 g(std::numeric_limits<float128>::lowest());
|
||||
static_assert(fpclassify(g) == FP_NORMAL);
|
||||
constexpr float128 h(std::numeric_limits<float128>::round_error());
|
||||
static_assert(fpclassify(h) == FP_NORMAL);
|
||||
constexpr float128 i(std::numeric_limits<float128>::denorm_min());
|
||||
static_assert(fpclassify(i) == FP_SUBNORMAL);
|
||||
constexpr float128 j(-std::numeric_limits<float128>::denorm_min());
|
||||
static_assert(fpclassify(j) == FP_SUBNORMAL);
|
||||
constexpr float128 k(std::numeric_limits<float128>::infinity());
|
||||
static_assert(fpclassify(k) == FP_INFINITE);
|
||||
static_assert(isinf(k));
|
||||
static_assert(!isnan(k));
|
||||
constexpr float128 l(-std::numeric_limits<float128>::infinity());
|
||||
static_assert(fpclassify(l) == FP_INFINITE);
|
||||
static_assert(isinf(l));
|
||||
static_assert(!isnan(l));
|
||||
}
|
||||
std::cout << "Done!" << std::endl;
|
||||
}
|
||||
21
test/standalone_test_arithmetic_ab.cpp
Normal file
21
test/standalone_test_arithmetic_ab.cpp
Normal file
@@ -0,0 +1,21 @@
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Copyright 2012 - 2021 John Maddock.
|
||||
// Copyright 2021 Matt Borland. Distributed under the Boost
|
||||
// Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define _SCL_SECURE_NO_WARNINGS
|
||||
#endif
|
||||
|
||||
#include "../performance/arithmetic_backend.hpp"
|
||||
|
||||
#include "test_arithmetic.hpp"
|
||||
|
||||
int main()
|
||||
{
|
||||
test<boost::multiprecision::number<boost::multiprecision::arithmetic_backend<double>>>();
|
||||
test<boost::multiprecision::number<boost::multiprecision::arithmetic_backend<int>>>();
|
||||
test<boost::multiprecision::number<boost::multiprecision::arithmetic_backend<unsigned>>>();
|
||||
return boost::report_errors();
|
||||
}
|
||||
23
test/standalone_test_arithmetic_complex128.cpp
Normal file
23
test/standalone_test_arithmetic_complex128.cpp
Normal file
@@ -0,0 +1,23 @@
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Copyright 2012-2021 John Maddock.
|
||||
// Copyright 2021 Matt Borland. Distributed under the Boost
|
||||
// Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#define BOOST_MP_STANDALONE
|
||||
|
||||
#ifdef BOOST_HAS_FLOAT128
|
||||
#include <boost/multiprecision/complex128.hpp>
|
||||
#endif
|
||||
|
||||
#include "libs/multiprecision/test/test_arithmetic.hpp"
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifdef BOOST_HAS_FLOAT128
|
||||
test<boost::multiprecision::complex128>();
|
||||
#endif
|
||||
return boost::report_errors();
|
||||
}
|
||||
27
test/standalone_test_arithmetic_cpp_bin_float.cpp
Normal file
27
test/standalone_test_arithmetic_cpp_bin_float.cpp
Normal file
@@ -0,0 +1,27 @@
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Copyright 2012 - 2021 John Maddock.
|
||||
// Copyright 2021 Matt Borland. Distributed under the Boost
|
||||
// Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include "libs/multiprecision/test/test_arithmetic.hpp"
|
||||
|
||||
#define BOOST_MP_STANDALONE
|
||||
|
||||
#include <boost/multiprecision/cpp_bin_float.hpp>
|
||||
|
||||
template <unsigned Digits, boost::multiprecision::backends::digit_base_type DigitBase, class Allocator, class Exponent, Exponent MinExponent, Exponent MaxExponent, boost::multiprecision::expression_template_option ET>
|
||||
struct related_type<boost::multiprecision::number<boost::multiprecision::cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinExponent, MaxExponent>, ET> >
|
||||
{
|
||||
using number_type = boost::multiprecision::number<boost::multiprecision::cpp_bin_float<Digits, DigitBase, Allocator, Exponent, MinExponent, MaxExponent>, ET>;
|
||||
using type = boost::multiprecision::number<boost::multiprecision::cpp_bin_float<((std::numeric_limits<number_type>::digits / 2) > std::numeric_limits<long double>::digits ? Digits / 2 : Digits), DigitBase, Allocator, Exponent, MinExponent, MaxExponent>, ET>;
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
test<boost::multiprecision::cpp_bin_float_50>();
|
||||
//test<boost::multiprecision::number<boost::multiprecision::cpp_bin_float<21>>>();
|
||||
//test<boost::multiprecision::number<boost::multiprecision::cpp_bin_float<1000, boost::multiprecision::digit_base_10, std::allocator<char>>>>();
|
||||
//test<boost::multiprecision::cpp_bin_float_quad>();
|
||||
return boost::report_errors();
|
||||
}
|
||||
23
test/standalone_test_arithmetic_cpp_dec_float.cpp
Normal file
23
test/standalone_test_arithmetic_cpp_dec_float.cpp
Normal file
@@ -0,0 +1,23 @@
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Copyright 2012 - 2021 John Maddock.
|
||||
// Copyright 2021 Matt Borland. Distributed under the Boost
|
||||
// Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include "test_arithmetic.hpp"
|
||||
|
||||
#define BOOST_MP_STANDALONE
|
||||
|
||||
#include <boost/multiprecision/cpp_dec_float.hpp>
|
||||
|
||||
template <unsigned D>
|
||||
struct related_type<boost::multiprecision::number<boost::multiprecision::cpp_dec_float<D>>>
|
||||
{
|
||||
using type = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<D / 2>>;
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
test<boost::multiprecision::cpp_dec_float_50>();
|
||||
return boost::report_errors();
|
||||
}
|
||||
32
test/standalone_test_arithmetic_cpp_int.cpp
Normal file
32
test/standalone_test_arithmetic_cpp_int.cpp
Normal file
@@ -0,0 +1,32 @@
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Copyright 2012 - 2021 John Maddock.
|
||||
// Copyright 2021 Matt Borland. Distributed under the Boost
|
||||
// Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include "test_arithmetic.hpp"
|
||||
|
||||
#define BOOST_MP_STANDALONE
|
||||
|
||||
#include <boost/multiprecision/cpp_int.hpp>
|
||||
|
||||
template <unsigned MinBits, unsigned MaxBits, boost::multiprecision::cpp_integer_type SignType, class Allocator, boost::multiprecision::expression_template_option ExpressionTemplates>
|
||||
struct is_twos_complement_integer<boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, boost::multiprecision::checked, Allocator>, ExpressionTemplates> > : public std::integral_constant<bool, false>
|
||||
{};
|
||||
|
||||
template <>
|
||||
struct related_type<boost::multiprecision::cpp_int>
|
||||
{
|
||||
using type = boost::multiprecision::int256_t;
|
||||
};
|
||||
template <unsigned MinBits, unsigned MaxBits, boost::multiprecision::cpp_integer_type SignType, boost::multiprecision::cpp_int_check_type Checked, class Allocator, boost::multiprecision::expression_template_option ET>
|
||||
struct related_type<boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, Checked, Allocator>, ET> >
|
||||
{
|
||||
using type = boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits / 2, MaxBits / 2, SignType, Checked, Allocator>, ET>;
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
test<boost::multiprecision::cpp_int>();
|
||||
return boost::report_errors();
|
||||
}
|
||||
37
test/standalone_test_arithmetic_cpp_rational.cpp
Normal file
37
test/standalone_test_arithmetic_cpp_rational.cpp
Normal file
@@ -0,0 +1,37 @@
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Copyright 2012 - 2021 John Maddock.
|
||||
// Copyright 2021 Matt Borland. Distributed under the Boost
|
||||
// Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include "test_arithmetic.hpp"
|
||||
|
||||
#define BOOST_MP_STANDALONE
|
||||
|
||||
#include <boost/multiprecision/cpp_int.hpp>
|
||||
|
||||
template <unsigned MinBits, unsigned MaxBits, boost::multiprecision::cpp_integer_type SignType, class Allocator, boost::multiprecision::expression_template_option ExpressionTemplates>
|
||||
struct is_twos_complement_integer<boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, boost::multiprecision::checked, Allocator>, ExpressionTemplates> > : public std::integral_constant<bool, false>
|
||||
{};
|
||||
|
||||
template <>
|
||||
struct related_type<boost::multiprecision::cpp_int>
|
||||
{
|
||||
using type = boost::multiprecision::int256_t;
|
||||
};
|
||||
template <>
|
||||
struct related_type<boost::multiprecision::cpp_rational>
|
||||
{
|
||||
using type = boost::multiprecision::cpp_int;
|
||||
};
|
||||
template <unsigned MinBits, unsigned MaxBits, boost::multiprecision::cpp_integer_type SignType, boost::multiprecision::cpp_int_check_type Checked, class Allocator, boost::multiprecision::expression_template_option ET>
|
||||
struct related_type<boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, Checked, Allocator>, ET> >
|
||||
{
|
||||
using type = boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits / 2, MaxBits / 2, SignType, Checked, Allocator>, ET>;
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
test<boost::multiprecision::cpp_rational>();
|
||||
return boost::report_errors();
|
||||
}
|
||||
21
test/standalone_test_arithmetic_float_128.cpp
Normal file
21
test/standalone_test_arithmetic_float_128.cpp
Normal file
@@ -0,0 +1,21 @@
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Copyright 2012 - 2021 John Maddock.
|
||||
// Copyright 2021 Matt Borland. Distributed under the Boost
|
||||
// Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define _SCL_SECURE_NO_WARNINGS
|
||||
#endif
|
||||
|
||||
#include "test_arithmetic.hpp"
|
||||
|
||||
#define BOOST_MP_STANDALONE
|
||||
|
||||
#include <boost/multiprecision/float128.hpp>
|
||||
|
||||
int main()
|
||||
{
|
||||
test<boost::multiprecision::float128>();
|
||||
return boost::report_errors();
|
||||
}
|
||||
32
test/standalone_test_arithmetic_int512.cpp
Normal file
32
test/standalone_test_arithmetic_int512.cpp
Normal file
@@ -0,0 +1,32 @@
|
||||
///////////////////////////////////////////////////////////////
|
||||
// Copyright 2012 - 2021 John Maddock.
|
||||
// Copyright 2021 Matt Borland. Distributed under the Boost
|
||||
// Software License, Version 1.0. (See accompanying file
|
||||
// LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include "test_arithmetic.hpp"
|
||||
|
||||
#define BOOST_MP_STANDALONE
|
||||
|
||||
#include <boost/multiprecision/cpp_int.hpp>
|
||||
|
||||
template <unsigned MinBits, unsigned MaxBits, boost::multiprecision::cpp_integer_type SignType, class Allocator, boost::multiprecision::expression_template_option ExpressionTemplates>
|
||||
struct is_twos_complement_integer<boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, boost::multiprecision::checked, Allocator>, ExpressionTemplates> > : public std::integral_constant<bool, false>
|
||||
{};
|
||||
|
||||
template <>
|
||||
struct related_type<boost::multiprecision::cpp_int>
|
||||
{
|
||||
using type = boost::multiprecision::int256_t;
|
||||
};
|
||||
template <unsigned MinBits, unsigned MaxBits, boost::multiprecision::cpp_integer_type SignType, boost::multiprecision::cpp_int_check_type Checked, class Allocator, boost::multiprecision::expression_template_option ET>
|
||||
struct related_type<boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits, MaxBits, SignType, Checked, Allocator>, ET> >
|
||||
{
|
||||
using type = boost::multiprecision::number<boost::multiprecision::cpp_int_backend<MinBits / 2, MaxBits / 2, SignType, Checked, Allocator>, ET>;
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
test<boost::multiprecision::int512_t>();
|
||||
return boost::report_errors();
|
||||
}
|
||||
Reference in New Issue
Block a user