Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
604 changes: 583 additions & 21 deletions .github/workflows/ci.yml

Large diffs are not rendered by default.

35 changes: 32 additions & 3 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,41 @@
# Copyright 2018, 2019 Peter Dimov
# Copyright 2025 James E. King III
# Copyright 2026 Sayan
# Distributed under 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(BoostTestJamfile OPTIONAL RESULT_VARIABLE HAVE_BOOST_TEST)
include(BoostTest OPTIONAL RESULT_VARIABLE HAVE_BOOST_TEST)

if(HAVE_BOOST_TEST)
if(NOT HAVE_BOOST_TEST)
return()
endif()

# The library relies on changing the FPU rounding mode at run time, which the
# compiler is only required to honour under strict FP semantics. Jamfile.v2 sets
# these per toolset; mirror them here. MSVC is tested first so that clang-cl
# gets /fp:strict rather than the GCC-style flag.
if(MSVC)
set(BOOST_TEST_COMPILE_OPTIONS /fp:strict)
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "IntelLLVM")
set(BOOST_TEST_COMPILE_OPTIONS -fp-model=strict)
elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
set(BOOST_TEST_COMPILE_OPTIONS -frounding-math)
endif()

set(BOOST_TEST_LINK_LIBRARIES Boost::numeric_interval Boost::core)

boost_test_jamfile(FILE Jamfile.v2 LINK_LIBRARIES Boost::numeric_interval Boost::core Boost::logic)
boost_test(TYPE compile SOURCES integer.cpp)

foreach(t add det fmod mul overflow pi pow cmp cmp_exp cmp_lex cmp_set test_float)
boost_test(TYPE run SOURCES ${t}.cpp)
endforeach()

boost_test(TYPE run SOURCES cmp_exn.cpp LINK_LIBRARIES Boost::logic)

# MSVC-only regression test (b2: <build>no <toolset>msvc:<build>yes).
if(MSVC)
boost_test(TYPE run SOURCES msvc_x64_flags.cpp)
endif()

# https://github.com/boostorg/interval/issues/15
# boost_test(TYPE run SOURCES cmp_tribool.cpp)
2 changes: 2 additions & 0 deletions test/Jamfile.v2
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ project
<toolset>gcc:<cxxflags>-frounding-math
<toolset>clang:<cxxflags>-frounding-math
<toolset>msvc:<cxxflags>/fp\:strict
<toolset>clang-win:<cxxflags>/fp\:strict
<toolset>intel:<cxxflags>-fp-model=strict
;

# bring in rules for testing
Expand Down
22 changes: 15 additions & 7 deletions test/add.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
#include <boost/numeric/interval/utility.hpp>
#include <boost/numeric/interval/policies.hpp>
#include <boost/core/lightweight_test.hpp>
#include <memory>
#include <algorithm>
#include <cstddef>
#include "bugs.hpp"

typedef enum { EXPR_VAR, EXPR_NEG, EXPR_UP, EXPR_DOWN, EXPR_ADD, EXPR_SUB } e_type;
Expand All @@ -25,6 +26,9 @@ struct pexpr {
expr *ptr;
expr* operator->() const { return ptr; }
pexpr(expr *p = NULL): ptr(p) { }
pexpr(const pexpr& o);
pexpr& operator=(pexpr o) { std::swap(ptr, o.ptr); return *this; }
~pexpr();
};

struct expr {
Expand All @@ -34,8 +38,12 @@ struct expr {
pexpr e1, e2;
};

// Each pexpr owns its node, and copying one clones the subtree.
pexpr::pexpr(const pexpr& o): ptr(o.ptr ? new expr(*o.ptr) : NULL) { }
pexpr::~pexpr() { delete ptr; }

pexpr var(int v) {
pexpr e = new expr;
pexpr e = new expr();
e->type = EXPR_VAR;
e->var = v;
return e;
Expand All @@ -49,7 +57,7 @@ pexpr operator+(pexpr a, pexpr b) {
if (a->type == EXPR_NEG) return b - a->e;
if (b->type == EXPR_NEG) return a - b->e;
if (a->type == EXPR_VAR && b->type == EXPR_VAR && a->var > b->var) return b + a;
pexpr c = new expr;
pexpr c = new expr();
c->type = EXPR_ADD;
c->e1 = a;
c->e2 = b;
Expand All @@ -58,22 +66,22 @@ pexpr operator+(pexpr a, pexpr b) {

pexpr operator-(pexpr a, pexpr b) {
if (b->type == EXPR_NEG) return a + b->e;
pexpr c = new expr;
pexpr c = new expr();
c->type = EXPR_SUB;
c->e1 = a;
c->e2 = b;
return c;
}

pexpr down(pexpr a) {
pexpr e = new expr;
pexpr e = new expr();
e->type = EXPR_DOWN;
e->e = a;
return e;
}

pexpr up(pexpr a) {
pexpr e = new expr;
pexpr e = new expr();
e->type = EXPR_UP;
e->e = a;
return e;
Expand All @@ -85,7 +93,7 @@ pexpr operator-(pexpr a) {
if (a->type == EXPR_DOWN) return up(-a->e);
if (a->type == EXPR_SUB) return a->e2 - a->e1;
if (a->type == EXPR_ADD) return -a->e1 - a->e2;
pexpr e = new expr;
pexpr e = new expr();
e->type = EXPR_NEG;
e->e = a;
return e;
Expand Down
2 changes: 1 addition & 1 deletion test/cmp_exn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ typedef boost::numeric::interval_lib::policies< empty_class, my_checking >
typedef boost::numeric::interval<int, my_policies> I;

#define BOOST_C_EXN(e) \
BOOST_TEST_THROWS(e, boost::numeric::interval_lib::comparison_error)
BOOST_TEST_THROWS((void)(e), boost::numeric::interval_lib::comparison_error)

static void test_cer()
{
Expand Down
1 change: 0 additions & 1 deletion test/suppressions.txt

This file was deleted.

Loading