mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2026-06-03 06:24:39 -04:00
Squashed 'boost/' content from commit b4feb19f2
git-subtree-dir: boost git-subtree-split: b4feb19f287ee92d87a9624b5d36b7cf46aeadeb
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
# Boost Interval Library test Jamfile
|
||||
#
|
||||
# Copyright 2003 Guillaume Melquiond
|
||||
#
|
||||
# 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)
|
||||
|
||||
project
|
||||
:
|
||||
source-location $(BOOST_ROOT)
|
||||
:
|
||||
requirements
|
||||
# Enable dynamic rounding on Tru64 (Alpha CPU).
|
||||
<toolset>hp_cxx,<os>OSF:<cflags>"-fprm d"
|
||||
<toolset>gcc,<os>OSF:<cflags>-mfp-rounding-mode=d
|
||||
;
|
||||
|
||||
# bring in rules for testing
|
||||
import testing ;
|
||||
|
||||
{
|
||||
test-suite numeric/interval :
|
||||
[ compile libs/numeric/interval/test/integer.cpp ]
|
||||
|
||||
[ run libs/numeric/interval/test/add.cpp ]
|
||||
[ run libs/numeric/interval/test/det.cpp ]
|
||||
[ run libs/numeric/interval/test/fmod.cpp ]
|
||||
[ run libs/numeric/interval/test/msvc_x64_flags.cpp ]
|
||||
[ run libs/numeric/interval/test/mul.cpp ]
|
||||
[ run libs/numeric/interval/test/overflow.cpp ]
|
||||
[ run libs/numeric/interval/test/pi.cpp ]
|
||||
[ run libs/numeric/interval/test/pow.cpp ]
|
||||
|
||||
[ run libs/numeric/interval/test/cmp.cpp
|
||||
../../../test/build//boost_test_exec_monitor/<link>static ]
|
||||
[ run libs/numeric/interval/test/cmp_exn.cpp
|
||||
../../../test/build//boost_test_exec_monitor/<link>static ]
|
||||
[ run libs/numeric/interval/test/cmp_exp.cpp
|
||||
../../../test/build//boost_test_exec_monitor/<link>static ]
|
||||
[ run libs/numeric/interval/test/cmp_lex.cpp
|
||||
../../../test/build//boost_test_exec_monitor/<link>static ]
|
||||
[ run libs/numeric/interval/test/cmp_set.cpp
|
||||
../../../test/build//boost_test_exec_monitor/<link>static ]
|
||||
[ run libs/numeric/interval/test/cmp_tribool.cpp
|
||||
../../../test/build//boost_test_exec_monitor/<link>static ]
|
||||
[ run libs/numeric/interval/test/test_float.cpp
|
||||
../../../test/build//boost_test_exec_monitor/<link>static ]
|
||||
;
|
||||
}
|
||||
@@ -0,0 +1,243 @@
|
||||
/* Boost test/add.cpp
|
||||
* test with symbolic operations if the addition algorithm is correct
|
||||
*
|
||||
* Copyright 2002-2003 Guillaume Melquiond
|
||||
*
|
||||
* 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 <boost/numeric/interval/interval.hpp>
|
||||
#include <boost/numeric/interval/arith.hpp>
|
||||
#include <boost/numeric/interval/rounding.hpp>
|
||||
#include <boost/numeric/interval/rounded_arith.hpp>
|
||||
#include <boost/numeric/interval/utility.hpp>
|
||||
#include <boost/numeric/interval/policies.hpp>
|
||||
#include <boost/test/minimal.hpp>
|
||||
#include "bugs.hpp"
|
||||
|
||||
typedef enum { EXPR_VAR, EXPR_NEG, EXPR_UP, EXPR_DOWN, EXPR_ADD, EXPR_SUB } e_type;
|
||||
|
||||
struct expr;
|
||||
struct pexpr {
|
||||
expr *ptr;
|
||||
expr* operator->() { return ptr; }
|
||||
pexpr(expr *p = NULL): ptr(p) { }
|
||||
};
|
||||
|
||||
struct expr {
|
||||
e_type type;
|
||||
int var;
|
||||
pexpr e;
|
||||
pexpr e1, e2;
|
||||
};
|
||||
|
||||
pexpr var(int v) {
|
||||
pexpr e = new expr;
|
||||
e->type = EXPR_VAR;
|
||||
e->var = v;
|
||||
return e;
|
||||
}
|
||||
|
||||
pexpr operator+(pexpr, pexpr);
|
||||
pexpr operator-(pexpr, pexpr);
|
||||
pexpr operator-(pexpr);
|
||||
|
||||
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;
|
||||
c->type = EXPR_ADD;
|
||||
c->e1 = a;
|
||||
c->e2 = b;
|
||||
return c;
|
||||
}
|
||||
|
||||
pexpr operator-(pexpr a, pexpr b) {
|
||||
if (b->type == EXPR_NEG) return a + b->e;
|
||||
pexpr c = new expr;
|
||||
c->type = EXPR_SUB;
|
||||
c->e1 = a;
|
||||
c->e2 = b;
|
||||
return c;
|
||||
}
|
||||
|
||||
pexpr down(pexpr a) {
|
||||
pexpr e = new expr;
|
||||
e->type = EXPR_DOWN;
|
||||
e->e = a;
|
||||
return e;
|
||||
}
|
||||
|
||||
pexpr up(pexpr a) {
|
||||
pexpr e = new expr;
|
||||
e->type = EXPR_UP;
|
||||
e->e = a;
|
||||
return e;
|
||||
}
|
||||
|
||||
pexpr operator-(pexpr a) {
|
||||
if (a->type == EXPR_NEG) return a->e;
|
||||
if (a->type == EXPR_UP) return down(-a->e);
|
||||
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;
|
||||
e->type = EXPR_NEG;
|
||||
e->e = a;
|
||||
return e;
|
||||
}
|
||||
|
||||
bool operator==(pexpr a, pexpr b) {
|
||||
if (a->type != b->type) return false;
|
||||
if (a->type == EXPR_VAR) return a->var == b->var;
|
||||
if (a->type == EXPR_DOWN || a->type == EXPR_UP || a->type == EXPR_NEG)
|
||||
return a->e == b->e;
|
||||
return a->e1 == b->e1 && a->e2 == b->e2;
|
||||
}
|
||||
|
||||
bool operator<=(pexpr, pexpr) { return true; }
|
||||
|
||||
namespace boost {
|
||||
namespace numeric {
|
||||
namespace interval_lib {
|
||||
|
||||
template<>
|
||||
struct rounding_control<pexpr> {
|
||||
typedef enum { RND_U, RND_M, RND_D } rounding_mode;
|
||||
static rounding_mode mode;
|
||||
rounding_control() { mode = RND_M; }
|
||||
void get_rounding_mode(rounding_mode& m) { m = mode; }
|
||||
void set_rounding_mode(rounding_mode m) { mode = m; }
|
||||
void upward() { mode = RND_U; }
|
||||
void downward() { mode = RND_D; }
|
||||
pexpr force_rounding(pexpr a) {
|
||||
switch (mode) {
|
||||
case RND_U: return up(a);
|
||||
case RND_D: return down(a);
|
||||
default: throw "Unset rounding mode";
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
rounding_control<pexpr>::rounding_mode rounding_control<pexpr>::mode = RND_M;
|
||||
|
||||
} // namespace interval_lib
|
||||
} // namespace numeric
|
||||
} // namespace boost
|
||||
|
||||
template<class I>
|
||||
bool test_neg() {
|
||||
I a(var(0), var(1));
|
||||
return equal(-a, I(-var(1), -var(0)));
|
||||
}
|
||||
|
||||
template<class I>
|
||||
bool test_add() {
|
||||
I a(var(0), var(1)), b(var(2), var(3));
|
||||
return equal(a + b, I(down(var(0) + var(2)), up(var(1) + var(3))));
|
||||
}
|
||||
|
||||
template<class I>
|
||||
bool test_add1() {
|
||||
I a(var(0), var(1));
|
||||
return equal(a + var(2), I(down(var(0) + var(2)), up(var(1) + var(2))));
|
||||
}
|
||||
|
||||
template<class I>
|
||||
bool test_add2() {
|
||||
I a(var(0), var(1));
|
||||
return equal(var(2) + a, I(down(var(0) + var(2)), up(var(1) + var(2))));
|
||||
}
|
||||
|
||||
template<class I>
|
||||
bool test_sub() {
|
||||
I a(var(0), var(1)), b(var(2), var(3));
|
||||
return equal(a - b, I(down(var(0) - var(3)), up(var(1) - var(2))));
|
||||
}
|
||||
|
||||
template<class I>
|
||||
bool test_sub1() {
|
||||
I a(var(0), var(1));
|
||||
return equal(a - var(2), I(down(var(0) - var(2)), up(var(1) - var(2))));
|
||||
}
|
||||
|
||||
template<class I>
|
||||
bool test_sub2() {
|
||||
I a(var(0), var(1));
|
||||
return equal(var(2) - a, I(down(var(2) - var(1)), up(var(2) - var(0))));
|
||||
}
|
||||
|
||||
template<class I>
|
||||
bool test_addeq() {
|
||||
I a(var(0), var(1)), b(var(2), var(3));
|
||||
return equal(a += b, I(down(var(0) + var(2)), up(var(1) + var(3))));
|
||||
}
|
||||
|
||||
template<class I>
|
||||
bool test_addeq1() {
|
||||
I a(var(0), var(1));
|
||||
return equal(a += var(2), I(down(var(0) + var(2)), up(var(1) + var(2))));
|
||||
}
|
||||
|
||||
template<class I>
|
||||
bool test_subeq() {
|
||||
I a(var(0), var(1)), b(var(2), var(3));
|
||||
return equal(a -= b, I(down(var(0) - var(3)), up(var(1) - var(2))));
|
||||
}
|
||||
|
||||
template<class I>
|
||||
bool test_subeq1() {
|
||||
I a(var(0), var(1));
|
||||
return equal(a -= var(2), I(down(var(0) - var(2)), up(var(1) - var(2))));
|
||||
}
|
||||
|
||||
struct my_checking
|
||||
{
|
||||
static pexpr pos_inf() { throw; }
|
||||
static pexpr neg_inf() { throw; }
|
||||
static pexpr nan() { throw; }
|
||||
static bool is_nan(const pexpr&) { return false; }
|
||||
static pexpr empty_lower() { throw; }
|
||||
static pexpr empty_upper() { throw; }
|
||||
static bool is_empty(const pexpr&, const pexpr&) { return false; }
|
||||
};
|
||||
|
||||
template<class Rounding>
|
||||
struct my_interval {
|
||||
private:
|
||||
typedef boost::numeric::interval_lib::save_state<Rounding> my_rounding;
|
||||
typedef boost::numeric::interval_lib::policies<my_rounding, my_checking> my_policies;
|
||||
public:
|
||||
typedef boost::numeric::interval<pexpr, my_policies> type;
|
||||
};
|
||||
|
||||
int test_main(int, char *[]) {
|
||||
typedef my_interval<boost::numeric::interval_lib::rounded_arith_std<pexpr> >::type I1;
|
||||
typedef my_interval<boost::numeric::interval_lib::rounded_arith_opp<pexpr> >::type I2;
|
||||
BOOST_CHECK((test_neg<I1>()));
|
||||
BOOST_CHECK((test_neg<I2>()));
|
||||
BOOST_CHECK((test_add<I1>()));
|
||||
BOOST_CHECK((test_add<I2>()));
|
||||
BOOST_CHECK((test_add1<I1>()));
|
||||
BOOST_CHECK((test_add1<I2>()));
|
||||
BOOST_CHECK((test_add2<I1>()));
|
||||
BOOST_CHECK((test_add2<I2>()));
|
||||
BOOST_CHECK((test_sub<I1>()));
|
||||
BOOST_CHECK((test_sub<I2>()));
|
||||
BOOST_CHECK((test_sub1<I1>()));
|
||||
BOOST_CHECK((test_sub1<I2>()));
|
||||
BOOST_CHECK((test_sub2<I1>()));
|
||||
BOOST_CHECK((test_sub2<I2>()));
|
||||
BOOST_CHECK((test_addeq<I1>()));
|
||||
BOOST_CHECK((test_addeq<I2>()));
|
||||
BOOST_CHECK((test_addeq1<I1>()));
|
||||
BOOST_CHECK((test_addeq1<I2>()));
|
||||
BOOST_CHECK((test_subeq<I1>()));
|
||||
BOOST_CHECK((test_subeq<I2>()));
|
||||
BOOST_CHECK((test_subeq1<I1>()));
|
||||
BOOST_CHECK((test_subeq1<I2>()));
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/* Boost test/bugs.hpp
|
||||
* Handles namespace resolution quirks in older compilers and braindead
|
||||
* warnings [Herve, June 3rd 2003]
|
||||
*
|
||||
* Copyright 2002-2003 Hervé Brönnimann
|
||||
*
|
||||
* 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 <boost/config.hpp>
|
||||
|
||||
// Borland compiler complains about unused variables a bit easily and
|
||||
// incorrectly
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
namespace detail {
|
||||
|
||||
template <class T> inline void ignore_unused_variable_warning(const T&) { }
|
||||
|
||||
inline void ignore_warnings() {
|
||||
# ifdef BOOST_NUMERIC_INTERVAL_CONSTANTS_HPP
|
||||
using namespace boost::numeric::interval_lib::constants;
|
||||
ignore_unused_variable_warning( pi_f_l );
|
||||
ignore_unused_variable_warning( pi_f_u );
|
||||
ignore_unused_variable_warning( pi_d_l );
|
||||
ignore_unused_variable_warning( pi_d_u );
|
||||
# endif
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
// Some compilers are broken with respect to name resolution
|
||||
|
||||
#if defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP) || defined( __BORLANDC__)
|
||||
|
||||
using namespace boost;
|
||||
using namespace numeric;
|
||||
using namespace interval_lib;
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,215 @@
|
||||
/* Boost test/cmp.cpp
|
||||
* test standard comparison functions
|
||||
*
|
||||
* Copyright 2002-2003 Guillaume Melquiond
|
||||
*
|
||||
* 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 "cmp_header.hpp"
|
||||
|
||||
// comparisons between [1,2] and [3,4]
|
||||
|
||||
static void test_12_34() {
|
||||
const I a(1,2), b(3,4);
|
||||
|
||||
BOOST_CHECK(a < b);
|
||||
BOOST_CHECK(a <= b);
|
||||
BOOST_CHECK(!(a > b));
|
||||
BOOST_CHECK(!(a >= b));
|
||||
|
||||
BOOST_CHECK(b > a);
|
||||
BOOST_CHECK(b >= a);
|
||||
BOOST_CHECK(!(b < a));
|
||||
BOOST_CHECK(!(b <= a));
|
||||
|
||||
BOOST_CHECK(!(a == b));
|
||||
BOOST_CHECK(a != b);
|
||||
|
||||
# ifdef __BORLANDC__
|
||||
::detail::ignore_unused_variable_warning(a);
|
||||
::detail::ignore_unused_variable_warning(b);
|
||||
# endif
|
||||
}
|
||||
|
||||
// comparisons between [1,3] and [2,4]
|
||||
|
||||
static void test_13_24() {
|
||||
const I a(1,3), b(2,4);
|
||||
|
||||
BOOST_C_EXN(a < b);
|
||||
BOOST_C_EXN(a <= b);
|
||||
BOOST_C_EXN(a > b);
|
||||
BOOST_C_EXN(a >= b);
|
||||
|
||||
BOOST_C_EXN(b < a);
|
||||
BOOST_C_EXN(b <= a);
|
||||
BOOST_C_EXN(b > a);
|
||||
BOOST_C_EXN(b >= a);
|
||||
|
||||
BOOST_C_EXN(a == b);
|
||||
BOOST_C_EXN(a != b);
|
||||
|
||||
# ifdef __BORLANDC__
|
||||
::detail::ignore_unused_variable_warning(a);
|
||||
::detail::ignore_unused_variable_warning(b);
|
||||
# endif
|
||||
}
|
||||
|
||||
// comparisons between [1,2] and [2,3]
|
||||
|
||||
static void test_12_23() {
|
||||
const I a(1,2), b(2,3);
|
||||
|
||||
BOOST_C_EXN(a < b);
|
||||
BOOST_CHECK(a <= b);
|
||||
BOOST_CHECK(!(a > b));
|
||||
BOOST_C_EXN(a >= b);
|
||||
|
||||
BOOST_CHECK(!(b < a));
|
||||
BOOST_C_EXN(b <= a);
|
||||
BOOST_C_EXN(b > a);
|
||||
BOOST_CHECK(b >= a);
|
||||
|
||||
BOOST_C_EXN(a == b);
|
||||
BOOST_C_EXN(a != b);
|
||||
|
||||
# ifdef __BORLANDC__
|
||||
::detail::ignore_unused_variable_warning(a);
|
||||
::detail::ignore_unused_variable_warning(b);
|
||||
# endif
|
||||
}
|
||||
|
||||
// comparisons between [1,2] and 0
|
||||
|
||||
static void test_12_0() {
|
||||
const I a(1,2);
|
||||
const int b = 0;
|
||||
|
||||
BOOST_CHECK(!(a < b));
|
||||
BOOST_CHECK(!(a <= b));
|
||||
BOOST_CHECK(a > b);
|
||||
BOOST_CHECK(a >= b);
|
||||
|
||||
BOOST_CHECK(!(a == b));
|
||||
BOOST_CHECK(a != b);
|
||||
|
||||
# ifdef __BORLANDC__
|
||||
::detail::ignore_unused_variable_warning(a);
|
||||
::detail::ignore_unused_variable_warning(b);
|
||||
# endif
|
||||
}
|
||||
|
||||
// comparisons between [1,2] and 1
|
||||
|
||||
static void test_12_1() {
|
||||
const I a(1,2);
|
||||
const int b = 1;
|
||||
|
||||
BOOST_CHECK(!(a < b));
|
||||
BOOST_C_EXN(a <= b);
|
||||
BOOST_C_EXN(a > b);
|
||||
BOOST_CHECK(a >= b);
|
||||
|
||||
BOOST_C_EXN(a == b);
|
||||
BOOST_C_EXN(a != b);
|
||||
|
||||
# ifdef __BORLANDC__
|
||||
::detail::ignore_unused_variable_warning(a);
|
||||
::detail::ignore_unused_variable_warning(b);
|
||||
# endif
|
||||
}
|
||||
|
||||
// comparisons between [1,2] and 2
|
||||
|
||||
static void test_12_2() {
|
||||
const I a(1,2);
|
||||
const int b = 2;
|
||||
|
||||
BOOST_C_EXN(a < b);
|
||||
BOOST_CHECK(a <= b);
|
||||
BOOST_CHECK(!(a > b));
|
||||
BOOST_C_EXN(a >= b);
|
||||
|
||||
BOOST_C_EXN(a == b);
|
||||
BOOST_C_EXN(a != b);
|
||||
|
||||
# ifdef __BORLANDC__
|
||||
::detail::ignore_unused_variable_warning(a);
|
||||
::detail::ignore_unused_variable_warning(b);
|
||||
# endif
|
||||
}
|
||||
|
||||
// comparisons between [1,2] and 3
|
||||
|
||||
static void test_12_3() {
|
||||
const I a(1,2);
|
||||
const int b = 3;
|
||||
|
||||
BOOST_CHECK(a < b);
|
||||
BOOST_CHECK(a <= b);
|
||||
BOOST_CHECK(!(a > b));
|
||||
BOOST_CHECK(!(a >= b));
|
||||
|
||||
BOOST_CHECK(!(a == b));
|
||||
BOOST_CHECK(a != b);
|
||||
|
||||
# ifdef __BORLANDC__
|
||||
::detail::ignore_unused_variable_warning(a);
|
||||
::detail::ignore_unused_variable_warning(b);
|
||||
# endif
|
||||
}
|
||||
|
||||
// comparisons between [1,2] and [1,2]
|
||||
|
||||
static void test_12_12() {
|
||||
const I a(1,2), b(1,2);
|
||||
BOOST_C_EXN(a == b);
|
||||
BOOST_C_EXN(a != b);
|
||||
# ifdef __BORLANDC__
|
||||
::detail::ignore_unused_variable_warning(a);
|
||||
::detail::ignore_unused_variable_warning(b);
|
||||
# endif
|
||||
}
|
||||
|
||||
// comparisons between [1,1] and [1,1]
|
||||
|
||||
static void test_11_11() {
|
||||
const I a(1,1), b(1,1);
|
||||
BOOST_CHECK(a == b);
|
||||
BOOST_CHECK(!(a != b));
|
||||
# ifdef __BORLANDC__
|
||||
::detail::ignore_unused_variable_warning(a);
|
||||
::detail::ignore_unused_variable_warning(b);
|
||||
# endif
|
||||
}
|
||||
|
||||
// comparisons between [1,1] and 1
|
||||
|
||||
static void test_11_1() {
|
||||
const I a(1,1);
|
||||
const int b = 1;
|
||||
BOOST_CHECK(a == b);
|
||||
BOOST_CHECK(!(a != b));
|
||||
# ifdef __BORLANDC__
|
||||
::detail::ignore_unused_variable_warning(a);
|
||||
::detail::ignore_unused_variable_warning(b);
|
||||
# endif
|
||||
}
|
||||
|
||||
int test_main(int, char *[]) {
|
||||
test_12_34();
|
||||
test_13_24();
|
||||
test_12_23();
|
||||
test_12_0();
|
||||
test_12_1();
|
||||
test_12_2();
|
||||
test_12_3();
|
||||
test_12_12();
|
||||
test_11_11();
|
||||
test_11_1();
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,230 @@
|
||||
/* Boost test/cmp_exn.cpp
|
||||
* test policies with respect to exception throwing
|
||||
*
|
||||
* Copyright 2004 Guillaume Melquiond
|
||||
*
|
||||
* 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 <boost/numeric/interval/interval.hpp>
|
||||
#include <boost/numeric/interval/checking.hpp>
|
||||
#include <boost/numeric/interval/compare.hpp>
|
||||
#include <boost/numeric/interval/policies.hpp>
|
||||
#include <boost/numeric/interval/compare/tribool.hpp>
|
||||
#include <boost/test/test_tools.hpp>
|
||||
|
||||
struct my_checking
|
||||
{
|
||||
static int nan() { return -1; }
|
||||
static bool is_nan(int x) { return x < 0; }
|
||||
static int empty_lower() { return -1; }
|
||||
static int empty_upper() { return -1; }
|
||||
static bool is_empty(int l, int u) { return l == -1 && u == -1; }
|
||||
};
|
||||
|
||||
struct empty_class {};
|
||||
|
||||
typedef boost::numeric::interval_lib::policies< empty_class, my_checking >
|
||||
my_policies;
|
||||
|
||||
typedef boost::numeric::interval<int, my_policies> I;
|
||||
|
||||
#define BOOST_C_EXN(e) \
|
||||
BOOST_CHECK_THROW(e, boost::numeric::interval_lib::comparison_error)
|
||||
|
||||
static void test_cer()
|
||||
{
|
||||
I const a(I::empty()), b(1,2);
|
||||
int const c = 0, d = my_checking::nan();
|
||||
using namespace boost::numeric::interval_lib::compare::certain;
|
||||
|
||||
BOOST_C_EXN(a < b);
|
||||
BOOST_C_EXN(a <= b);
|
||||
BOOST_C_EXN(a > b);
|
||||
BOOST_C_EXN(a >= b);
|
||||
BOOST_C_EXN(a == b);
|
||||
BOOST_C_EXN(a != b);
|
||||
BOOST_C_EXN(b < a);
|
||||
BOOST_C_EXN(b <= a);
|
||||
BOOST_C_EXN(b > a);
|
||||
BOOST_C_EXN(b >= a);
|
||||
BOOST_C_EXN(b == a);
|
||||
BOOST_C_EXN(b != a);
|
||||
|
||||
BOOST_C_EXN(a < c);
|
||||
BOOST_C_EXN(a <= c);
|
||||
BOOST_C_EXN(a > c);
|
||||
BOOST_C_EXN(a >= c);
|
||||
BOOST_C_EXN(a == c);
|
||||
BOOST_C_EXN(a != c);
|
||||
BOOST_C_EXN(b < d);
|
||||
BOOST_C_EXN(b <= d);
|
||||
BOOST_C_EXN(b > d);
|
||||
BOOST_C_EXN(b >= d);
|
||||
BOOST_C_EXN(b == d);
|
||||
BOOST_C_EXN(b != d);
|
||||
}
|
||||
|
||||
static void test_def()
|
||||
{
|
||||
I const a(I::empty()), b(1,2);
|
||||
int const c = 0, d = my_checking::nan();
|
||||
|
||||
BOOST_C_EXN(a < b);
|
||||
BOOST_C_EXN(a <= b);
|
||||
BOOST_C_EXN(a > b);
|
||||
BOOST_C_EXN(a >= b);
|
||||
BOOST_C_EXN(a == b);
|
||||
BOOST_C_EXN(a != b);
|
||||
BOOST_C_EXN(b < a);
|
||||
BOOST_C_EXN(b <= a);
|
||||
BOOST_C_EXN(b > a);
|
||||
BOOST_C_EXN(b >= a);
|
||||
BOOST_C_EXN(b == a);
|
||||
BOOST_C_EXN(b != a);
|
||||
|
||||
BOOST_C_EXN(a < c);
|
||||
BOOST_C_EXN(a <= c);
|
||||
BOOST_C_EXN(a > c);
|
||||
BOOST_C_EXN(a >= c);
|
||||
BOOST_C_EXN(a == c);
|
||||
BOOST_C_EXN(a != c);
|
||||
BOOST_C_EXN(b < d);
|
||||
BOOST_C_EXN(b <= d);
|
||||
BOOST_C_EXN(b > d);
|
||||
BOOST_C_EXN(b >= d);
|
||||
BOOST_C_EXN(b == d);
|
||||
BOOST_C_EXN(b != d);
|
||||
}
|
||||
|
||||
static void test_lex()
|
||||
{
|
||||
I const a(I::empty()), b(1,2);
|
||||
int const c = 0, d = my_checking::nan();
|
||||
using namespace boost::numeric::interval_lib::compare::lexicographic;
|
||||
|
||||
BOOST_C_EXN(a < b);
|
||||
BOOST_C_EXN(a <= b);
|
||||
BOOST_C_EXN(a > b);
|
||||
BOOST_C_EXN(a >= b);
|
||||
BOOST_C_EXN(a == b);
|
||||
BOOST_C_EXN(a != b);
|
||||
BOOST_C_EXN(b < a);
|
||||
BOOST_C_EXN(b <= a);
|
||||
BOOST_C_EXN(b > a);
|
||||
BOOST_C_EXN(b >= a);
|
||||
BOOST_C_EXN(b == a);
|
||||
BOOST_C_EXN(b != a);
|
||||
|
||||
BOOST_C_EXN(a < c);
|
||||
BOOST_C_EXN(a <= c);
|
||||
BOOST_C_EXN(a > c);
|
||||
BOOST_C_EXN(a >= c);
|
||||
BOOST_C_EXN(a == c);
|
||||
BOOST_C_EXN(a != c);
|
||||
BOOST_C_EXN(b < d);
|
||||
BOOST_C_EXN(b <= d);
|
||||
BOOST_C_EXN(b > d);
|
||||
BOOST_C_EXN(b >= d);
|
||||
BOOST_C_EXN(b == d);
|
||||
BOOST_C_EXN(b != d);
|
||||
}
|
||||
|
||||
static void test_pos()
|
||||
{
|
||||
I const a(I::empty()), b(1,2);
|
||||
int const c = 0, d = my_checking::nan();
|
||||
using namespace boost::numeric::interval_lib::compare::possible;
|
||||
|
||||
BOOST_C_EXN(a < b);
|
||||
BOOST_C_EXN(a <= b);
|
||||
BOOST_C_EXN(a > b);
|
||||
BOOST_C_EXN(a >= b);
|
||||
BOOST_C_EXN(a == b);
|
||||
BOOST_C_EXN(a != b);
|
||||
BOOST_C_EXN(b < a);
|
||||
BOOST_C_EXN(b <= a);
|
||||
BOOST_C_EXN(b > a);
|
||||
BOOST_C_EXN(b >= a);
|
||||
BOOST_C_EXN(b == a);
|
||||
BOOST_C_EXN(b != a);
|
||||
|
||||
BOOST_C_EXN(a < c);
|
||||
BOOST_C_EXN(a <= c);
|
||||
BOOST_C_EXN(a > c);
|
||||
BOOST_C_EXN(a >= c);
|
||||
BOOST_C_EXN(a == c);
|
||||
BOOST_C_EXN(a != c);
|
||||
BOOST_C_EXN(b < d);
|
||||
BOOST_C_EXN(b <= d);
|
||||
BOOST_C_EXN(b > d);
|
||||
BOOST_C_EXN(b >= d);
|
||||
BOOST_C_EXN(b == d);
|
||||
BOOST_C_EXN(b != d);
|
||||
}
|
||||
|
||||
static void test_set()
|
||||
{
|
||||
I const a(I::empty()), b(1,2);
|
||||
int const c = 0;
|
||||
using namespace boost::numeric::interval_lib::compare::set;
|
||||
|
||||
BOOST_C_EXN(a < c);
|
||||
BOOST_C_EXN(a <= c);
|
||||
BOOST_C_EXN(a > c);
|
||||
BOOST_C_EXN(a >= c);
|
||||
BOOST_C_EXN(a == c);
|
||||
BOOST_C_EXN(a != c);
|
||||
BOOST_C_EXN(b < c);
|
||||
BOOST_C_EXN(b <= c);
|
||||
BOOST_C_EXN(b > c);
|
||||
BOOST_C_EXN(b >= c);
|
||||
BOOST_C_EXN(b == c);
|
||||
BOOST_C_EXN(b != c);
|
||||
}
|
||||
|
||||
static void test_tri()
|
||||
{
|
||||
I const a(I::empty()), b(1,2);
|
||||
int const c = 0, d = my_checking::nan();
|
||||
using namespace boost::numeric::interval_lib::compare::tribool;
|
||||
|
||||
BOOST_C_EXN(a < b);
|
||||
BOOST_C_EXN(a <= b);
|
||||
BOOST_C_EXN(a > b);
|
||||
BOOST_C_EXN(a >= b);
|
||||
BOOST_C_EXN(a == b);
|
||||
BOOST_C_EXN(a != b);
|
||||
BOOST_C_EXN(b < a);
|
||||
BOOST_C_EXN(b <= a);
|
||||
BOOST_C_EXN(b > a);
|
||||
BOOST_C_EXN(b >= a);
|
||||
BOOST_C_EXN(b == a);
|
||||
BOOST_C_EXN(b != a);
|
||||
|
||||
BOOST_C_EXN(a < c);
|
||||
BOOST_C_EXN(a <= c);
|
||||
BOOST_C_EXN(a > c);
|
||||
BOOST_C_EXN(a >= c);
|
||||
BOOST_C_EXN(a == c);
|
||||
BOOST_C_EXN(a != c);
|
||||
BOOST_C_EXN(b < d);
|
||||
BOOST_C_EXN(b <= d);
|
||||
BOOST_C_EXN(b > d);
|
||||
BOOST_C_EXN(b >= d);
|
||||
BOOST_C_EXN(b == d);
|
||||
BOOST_C_EXN(b != d);
|
||||
}
|
||||
|
||||
int test_main(int, char *[]) {
|
||||
test_cer();
|
||||
test_def();
|
||||
test_lex();
|
||||
test_pos();
|
||||
test_set();
|
||||
test_tri();
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,366 @@
|
||||
/* Boost test/cmp_exp.cpp
|
||||
* test explicit comparison functions
|
||||
*
|
||||
* Copyright 2002-2003 Guillaume Melquiond
|
||||
*
|
||||
* 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 "cmp_header.hpp"
|
||||
|
||||
// comparisons between [1,2] and [3,4]
|
||||
|
||||
static void test_12_34() {
|
||||
const I a(1,2), b(3,4);
|
||||
|
||||
BOOST_CHECK(cerlt(a, b));
|
||||
BOOST_CHECK(cerle(a, b));
|
||||
BOOST_CHECK(!cergt(a, b));
|
||||
BOOST_CHECK(!cerge(a, b));
|
||||
|
||||
BOOST_CHECK(!cerlt(b, a));
|
||||
BOOST_CHECK(!cerle(b, a));
|
||||
BOOST_CHECK(cergt(b, a));
|
||||
BOOST_CHECK(cerge(b, a));
|
||||
|
||||
BOOST_CHECK(poslt(a, b));
|
||||
BOOST_CHECK(posle(a, b));
|
||||
BOOST_CHECK(!posgt(a, b));
|
||||
BOOST_CHECK(!posge(a, b));
|
||||
|
||||
BOOST_CHECK(!poslt(b, a));
|
||||
BOOST_CHECK(!posle(b, a));
|
||||
BOOST_CHECK(posgt(b, a));
|
||||
BOOST_CHECK(posge(b, a));
|
||||
|
||||
BOOST_CHECK(!cereq(a, b));
|
||||
BOOST_CHECK(cerne(a, b));
|
||||
BOOST_CHECK(!poseq(a, b));
|
||||
BOOST_CHECK(posne(a, b));
|
||||
|
||||
BOOST_CHECK(!cereq(b, a));
|
||||
BOOST_CHECK(cerne(b, a));
|
||||
BOOST_CHECK(!poseq(b, a));
|
||||
BOOST_CHECK(posne(b, a));
|
||||
|
||||
# ifdef __BORLANDC__
|
||||
::detail::ignore_unused_variable_warning(a);
|
||||
::detail::ignore_unused_variable_warning(b);
|
||||
# endif
|
||||
}
|
||||
|
||||
// comparisons between [1,3] and [2,4]
|
||||
|
||||
static void test_13_24() {
|
||||
const I a(1,3), b(2,4);
|
||||
|
||||
BOOST_CHECK(!cerlt(a, b));
|
||||
BOOST_CHECK(!cerle(a, b));
|
||||
BOOST_CHECK(!cergt(a, b));
|
||||
BOOST_CHECK(!cerge(a, b));
|
||||
|
||||
BOOST_CHECK(!cerlt(b, a));
|
||||
BOOST_CHECK(!cerle(b, a));
|
||||
BOOST_CHECK(!cergt(b, a));
|
||||
BOOST_CHECK(!cerge(b, a));
|
||||
|
||||
BOOST_CHECK(poslt(a, b));
|
||||
BOOST_CHECK(posle(a, b));
|
||||
BOOST_CHECK(posgt(a, b));
|
||||
BOOST_CHECK(posge(a, b));
|
||||
|
||||
BOOST_CHECK(poslt(b, a));
|
||||
BOOST_CHECK(posle(b, a));
|
||||
BOOST_CHECK(posgt(b, a));
|
||||
BOOST_CHECK(posge(b, a));
|
||||
|
||||
BOOST_CHECK(!cereq(a, b));
|
||||
BOOST_CHECK(!cerne(a, b));
|
||||
BOOST_CHECK(poseq(a, b));
|
||||
BOOST_CHECK(posne(a, b));
|
||||
|
||||
BOOST_CHECK(!cereq(b, a));
|
||||
BOOST_CHECK(!cerne(b, a));
|
||||
BOOST_CHECK(poseq(b, a));
|
||||
BOOST_CHECK(posne(b, a));
|
||||
|
||||
# ifdef __BORLANDC__
|
||||
::detail::ignore_unused_variable_warning(a);
|
||||
::detail::ignore_unused_variable_warning(b);
|
||||
# endif
|
||||
}
|
||||
|
||||
// comparisons between [1,2] and [2,3]
|
||||
|
||||
static void test_12_23() {
|
||||
const I a(1,2), b(2,3);
|
||||
|
||||
BOOST_CHECK(!cerlt(a, b));
|
||||
BOOST_CHECK(cerle(a, b));
|
||||
BOOST_CHECK(!cergt(a, b));
|
||||
BOOST_CHECK(!cerge(a, b));
|
||||
|
||||
BOOST_CHECK(!cerlt(b, a));
|
||||
BOOST_CHECK(!cerle(b, a));
|
||||
BOOST_CHECK(!cergt(b, a));
|
||||
BOOST_CHECK(cerge(b, a));
|
||||
|
||||
BOOST_CHECK(poslt(a, b));
|
||||
BOOST_CHECK(posle(a, b));
|
||||
BOOST_CHECK(!posgt(a, b));
|
||||
BOOST_CHECK(posge(a, b));
|
||||
|
||||
BOOST_CHECK(!poslt(b, a));
|
||||
BOOST_CHECK(posle(b, a));
|
||||
BOOST_CHECK(posgt(b, a));
|
||||
BOOST_CHECK(posge(b, a));
|
||||
|
||||
BOOST_CHECK(!cereq(a, b));
|
||||
BOOST_CHECK(!cerne(a, b));
|
||||
BOOST_CHECK(poseq(a, b));
|
||||
BOOST_CHECK(posne(a, b));
|
||||
|
||||
BOOST_CHECK(!cereq(b, a));
|
||||
BOOST_CHECK(!cerne(b, a));
|
||||
BOOST_CHECK(poseq(b, a));
|
||||
BOOST_CHECK(posne(b, a));
|
||||
|
||||
# ifdef __BORLANDC__
|
||||
::detail::ignore_unused_variable_warning(a);
|
||||
::detail::ignore_unused_variable_warning(b);
|
||||
# endif
|
||||
}
|
||||
|
||||
// comparisons between [1,2] and 0
|
||||
|
||||
static void test_12_0() {
|
||||
const I a(1,2);
|
||||
const int b = 0;
|
||||
|
||||
BOOST_CHECK(!cerlt(a, b));
|
||||
BOOST_CHECK(!cerle(a, b));
|
||||
BOOST_CHECK(cergt(a, b));
|
||||
BOOST_CHECK(cerge(a, b));
|
||||
|
||||
BOOST_CHECK(cerlt(b, a));
|
||||
BOOST_CHECK(cerle(b, a));
|
||||
BOOST_CHECK(!cergt(b, a));
|
||||
BOOST_CHECK(!cerge(b, a));
|
||||
|
||||
BOOST_CHECK(!poslt(a, b));
|
||||
BOOST_CHECK(!posle(a, b));
|
||||
BOOST_CHECK(posgt(a, b));
|
||||
BOOST_CHECK(posge(a, b));
|
||||
|
||||
BOOST_CHECK(poslt(b, a));
|
||||
BOOST_CHECK(posle(b, a));
|
||||
BOOST_CHECK(!posgt(b, a));
|
||||
BOOST_CHECK(!posge(b, a));
|
||||
|
||||
BOOST_CHECK(!cereq(a, b));
|
||||
BOOST_CHECK(cerne(a, b));
|
||||
BOOST_CHECK(!poseq(a, b));
|
||||
BOOST_CHECK(posne(a, b));
|
||||
|
||||
BOOST_CHECK(!cereq(b, a));
|
||||
BOOST_CHECK(cerne(b, a));
|
||||
BOOST_CHECK(!poseq(b, a));
|
||||
BOOST_CHECK(posne(b, a));
|
||||
|
||||
# ifdef __BORLANDC__
|
||||
::detail::ignore_unused_variable_warning(a);
|
||||
::detail::ignore_unused_variable_warning(b);
|
||||
# endif
|
||||
}
|
||||
|
||||
// comparisons between [1,2] and 1
|
||||
|
||||
static void test_12_1() {
|
||||
const I a(1,2);
|
||||
const int b = 1;
|
||||
|
||||
BOOST_CHECK(!cerlt(a, b));
|
||||
BOOST_CHECK(!cerle(a, b));
|
||||
BOOST_CHECK(!cergt(a, b));
|
||||
BOOST_CHECK(cerge(a, b));
|
||||
|
||||
BOOST_CHECK(!cerlt(b, a));
|
||||
BOOST_CHECK(cerle(b, a));
|
||||
BOOST_CHECK(!cergt(b, a));
|
||||
BOOST_CHECK(!cerge(b, a));
|
||||
|
||||
BOOST_CHECK(!poslt(a, b));
|
||||
BOOST_CHECK(posle(a, b));
|
||||
BOOST_CHECK(posgt(a, b));
|
||||
BOOST_CHECK(posge(a, b));
|
||||
|
||||
BOOST_CHECK(poslt(b, a));
|
||||
BOOST_CHECK(posle(b, a));
|
||||
BOOST_CHECK(!posgt(b, a));
|
||||
BOOST_CHECK(posge(b, a));
|
||||
|
||||
BOOST_CHECK(!cereq(a, b));
|
||||
BOOST_CHECK(!cerne(a, b));
|
||||
BOOST_CHECK(poseq(a, b));
|
||||
BOOST_CHECK(posne(a, b));
|
||||
|
||||
BOOST_CHECK(!cereq(b, a));
|
||||
BOOST_CHECK(!cerne(b, a));
|
||||
BOOST_CHECK(poseq(b, a));
|
||||
BOOST_CHECK(posne(b, a));
|
||||
|
||||
# ifdef __BORLANDC__
|
||||
::detail::ignore_unused_variable_warning(a);
|
||||
::detail::ignore_unused_variable_warning(b);
|
||||
# endif
|
||||
}
|
||||
|
||||
// comparisons between [1,2] and 2
|
||||
|
||||
static void test_12_2() {
|
||||
const I a(1,2);
|
||||
const int b = 2;
|
||||
|
||||
BOOST_CHECK(!cerlt(a, b));
|
||||
BOOST_CHECK(cerle(a, b));
|
||||
BOOST_CHECK(!cergt(a, b));
|
||||
BOOST_CHECK(!cerge(a, b));
|
||||
|
||||
BOOST_CHECK(!cerlt(b, a));
|
||||
BOOST_CHECK(!cerle(b, a));
|
||||
BOOST_CHECK(!cergt(b, a));
|
||||
BOOST_CHECK(cerge(b, a));
|
||||
|
||||
BOOST_CHECK(poslt(a, b));
|
||||
BOOST_CHECK(posle(a, b));
|
||||
BOOST_CHECK(!posgt(a, b));
|
||||
BOOST_CHECK(posge(a, b));
|
||||
|
||||
BOOST_CHECK(!poslt(b, a));
|
||||
BOOST_CHECK(posle(b, a));
|
||||
BOOST_CHECK(posgt(b, a));
|
||||
BOOST_CHECK(posge(b, a));
|
||||
|
||||
BOOST_CHECK(!cereq(a, b));
|
||||
BOOST_CHECK(!cerne(a, b));
|
||||
BOOST_CHECK(poseq(a, b));
|
||||
BOOST_CHECK(posne(a, b));
|
||||
|
||||
BOOST_CHECK(!cereq(b, a));
|
||||
BOOST_CHECK(!cerne(b, a));
|
||||
BOOST_CHECK(poseq(b, a));
|
||||
BOOST_CHECK(posne(b, a));
|
||||
|
||||
# ifdef __BORLANDC__
|
||||
::detail::ignore_unused_variable_warning(a);
|
||||
::detail::ignore_unused_variable_warning(b);
|
||||
# endif
|
||||
}
|
||||
|
||||
// comparisons between [1,2] and 3
|
||||
|
||||
static void test_12_3() {
|
||||
const I a(1,2);
|
||||
const int b = 3;
|
||||
|
||||
BOOST_CHECK(cerlt(a, b));
|
||||
BOOST_CHECK(cerle(a, b));
|
||||
BOOST_CHECK(!cergt(a, b));
|
||||
BOOST_CHECK(!cerge(a, b));
|
||||
|
||||
BOOST_CHECK(!cerlt(b, a));
|
||||
BOOST_CHECK(!cerle(b, a));
|
||||
BOOST_CHECK(cergt(b, a));
|
||||
BOOST_CHECK(cerge(b, a));
|
||||
|
||||
BOOST_CHECK(poslt(a, b));
|
||||
BOOST_CHECK(posle(a, b));
|
||||
BOOST_CHECK(!posgt(a, b));
|
||||
BOOST_CHECK(!posge(a, b));
|
||||
|
||||
BOOST_CHECK(!poslt(b, a));
|
||||
BOOST_CHECK(!posle(b, a));
|
||||
BOOST_CHECK(posgt(b, a));
|
||||
BOOST_CHECK(posge(b, a));
|
||||
|
||||
BOOST_CHECK(!cereq(a, b));
|
||||
BOOST_CHECK(cerne(a, b));
|
||||
BOOST_CHECK(!poseq(a, b));
|
||||
BOOST_CHECK(posne(a, b));
|
||||
|
||||
BOOST_CHECK(!cereq(b, a));
|
||||
BOOST_CHECK(cerne(b, a));
|
||||
BOOST_CHECK(!poseq(b, a));
|
||||
BOOST_CHECK(posne(b, a));
|
||||
|
||||
# ifdef __BORLANDC__
|
||||
::detail::ignore_unused_variable_warning(a);
|
||||
::detail::ignore_unused_variable_warning(b);
|
||||
# endif
|
||||
}
|
||||
|
||||
static void test_12_12() {
|
||||
const I a(1,2), b(1,2);
|
||||
BOOST_CHECK(!cereq(a, b));
|
||||
BOOST_CHECK(!cerne(a, b));
|
||||
BOOST_CHECK(poseq(a, b));
|
||||
BOOST_CHECK(posne(a, b));
|
||||
BOOST_CHECK(!cereq(b, a));
|
||||
BOOST_CHECK(!cerne(b, a));
|
||||
BOOST_CHECK(poseq(b, a));
|
||||
BOOST_CHECK(posne(b, a));
|
||||
# ifdef __BORLANDC__
|
||||
::detail::ignore_unused_variable_warning(a);
|
||||
::detail::ignore_unused_variable_warning(b);
|
||||
# endif
|
||||
}
|
||||
|
||||
static void test_11_11() {
|
||||
const I a(1,1), b(1,1);
|
||||
BOOST_CHECK(cereq(a, b));
|
||||
BOOST_CHECK(!cerne(a, b));
|
||||
BOOST_CHECK(poseq(a, b));
|
||||
BOOST_CHECK(!posne(a, b));
|
||||
BOOST_CHECK(cereq(b, a));
|
||||
BOOST_CHECK(!cerne(b, a));
|
||||
BOOST_CHECK(poseq(b, a));
|
||||
BOOST_CHECK(!posne(b, a));
|
||||
# ifdef __BORLANDC__
|
||||
::detail::ignore_unused_variable_warning(a);
|
||||
::detail::ignore_unused_variable_warning(b);
|
||||
# endif
|
||||
}
|
||||
|
||||
static void test_11_1() {
|
||||
const I a(1,1);
|
||||
const int b = 1;
|
||||
BOOST_CHECK(cereq(a, b));
|
||||
BOOST_CHECK(!cerne(a, b));
|
||||
BOOST_CHECK(poseq(a, b));
|
||||
BOOST_CHECK(!posne(a, b));
|
||||
BOOST_CHECK(cereq(b, a));
|
||||
BOOST_CHECK(!cerne(b, a));
|
||||
BOOST_CHECK(poseq(b, a));
|
||||
BOOST_CHECK(!posne(b, a));
|
||||
# ifdef __BORLANDC__
|
||||
::detail::ignore_unused_variable_warning(a);
|
||||
::detail::ignore_unused_variable_warning(b);
|
||||
# endif
|
||||
}
|
||||
|
||||
int test_main(int, char *[]) {
|
||||
test_12_34();
|
||||
test_13_24();
|
||||
test_12_23();
|
||||
test_12_0();
|
||||
test_12_1();
|
||||
test_12_2();
|
||||
test_12_3();
|
||||
test_12_12();
|
||||
test_11_11();
|
||||
test_11_1();
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
/* Boost test/cmp_header.hpp header file
|
||||
*
|
||||
* Copyright 2003 Guillaume Melquiond
|
||||
*
|
||||
* 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 <boost/numeric/interval/interval.hpp>
|
||||
#include <boost/numeric/interval/checking.hpp>
|
||||
#include <boost/numeric/interval/compare.hpp>
|
||||
#include <boost/numeric/interval/policies.hpp>
|
||||
#include <boost/test/test_tools.hpp>
|
||||
#include "bugs.hpp"
|
||||
|
||||
struct empty_class {};
|
||||
|
||||
typedef boost::numeric::interval_lib::policies
|
||||
<empty_class, boost::numeric::interval_lib::checking_base<int> >
|
||||
my_policies;
|
||||
|
||||
typedef boost::numeric::interval<int, my_policies> I;
|
||||
|
||||
#define BOOST_C_EXN(e) \
|
||||
BOOST_CHECK_THROW(e, boost::numeric::interval_lib::comparison_error)
|
||||
@@ -0,0 +1,217 @@
|
||||
/* Boost test/cmp_lex.cpp
|
||||
* test compare::lexicographic
|
||||
*
|
||||
* Copyright 2002-2003 Guillaume Melquiond
|
||||
*
|
||||
* 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 "cmp_header.hpp"
|
||||
|
||||
using namespace boost::numeric::interval_lib::compare::lexicographic;
|
||||
|
||||
// comparisons between [1,2] and [3,4]
|
||||
|
||||
static void test_12_34() {
|
||||
const I a(1,2), b(3,4);
|
||||
|
||||
BOOST_CHECK(a < b);
|
||||
BOOST_CHECK(a <= b);
|
||||
BOOST_CHECK(!(a > b));
|
||||
BOOST_CHECK(!(a >= b));
|
||||
|
||||
BOOST_CHECK(b > a);
|
||||
BOOST_CHECK(b >= a);
|
||||
BOOST_CHECK(!(b < a));
|
||||
BOOST_CHECK(!(b <= a));
|
||||
|
||||
BOOST_CHECK(!(a == b));
|
||||
BOOST_CHECK(a != b);
|
||||
|
||||
# ifdef __BORLANDC__
|
||||
::detail::ignore_unused_variable_warning(a);
|
||||
::detail::ignore_unused_variable_warning(b);
|
||||
# endif
|
||||
}
|
||||
|
||||
// comparisons between [1,3] and [2,4]
|
||||
|
||||
static void test_13_24() {
|
||||
const I a(1,3), b(2,4);
|
||||
|
||||
BOOST_CHECK(a < b);
|
||||
BOOST_CHECK(a <= b);
|
||||
BOOST_CHECK(!(a > b));
|
||||
BOOST_CHECK(!(a >= b));
|
||||
|
||||
BOOST_CHECK(!(b < a));
|
||||
BOOST_CHECK(!(b <= a));
|
||||
BOOST_CHECK(b > a);
|
||||
BOOST_CHECK(b >= a);
|
||||
|
||||
BOOST_CHECK(!(a == b));
|
||||
BOOST_CHECK(a != b);
|
||||
|
||||
# ifdef __BORLANDC__
|
||||
::detail::ignore_unused_variable_warning(a);
|
||||
::detail::ignore_unused_variable_warning(b);
|
||||
# endif
|
||||
}
|
||||
|
||||
// comparisons between [1,2] and [2,3]
|
||||
|
||||
static void test_12_23() {
|
||||
const I a(1,2), b(2,3);
|
||||
|
||||
BOOST_CHECK(a < b);
|
||||
BOOST_CHECK(a <= b);
|
||||
BOOST_CHECK(!(a > b));
|
||||
BOOST_CHECK(!(a >= b));
|
||||
|
||||
BOOST_CHECK(!(b < a));
|
||||
BOOST_CHECK(!(b <= a));
|
||||
BOOST_CHECK(b > a);
|
||||
BOOST_CHECK(b >= a);
|
||||
|
||||
BOOST_CHECK(!(a == b));
|
||||
BOOST_CHECK(a != b);
|
||||
|
||||
# ifdef __BORLANDC__
|
||||
::detail::ignore_unused_variable_warning(a);
|
||||
::detail::ignore_unused_variable_warning(b);
|
||||
# endif
|
||||
}
|
||||
|
||||
// comparisons between [1,2] and 0
|
||||
|
||||
static void test_12_0() {
|
||||
const I a(1,2);
|
||||
const int b = 0;
|
||||
|
||||
BOOST_CHECK(!(a < b));
|
||||
BOOST_CHECK(!(a <= b));
|
||||
BOOST_CHECK(a > b);
|
||||
BOOST_CHECK(a >= b);
|
||||
|
||||
BOOST_CHECK(!(a == b));
|
||||
BOOST_CHECK(a != b);
|
||||
|
||||
# ifdef __BORLANDC__
|
||||
::detail::ignore_unused_variable_warning(a);
|
||||
::detail::ignore_unused_variable_warning(b);
|
||||
# endif
|
||||
}
|
||||
|
||||
// comparisons between [1,2] and 1
|
||||
|
||||
static void test_12_1() {
|
||||
const I a(1,2);
|
||||
const int b = 1;
|
||||
|
||||
BOOST_CHECK(!(a < b));
|
||||
BOOST_CHECK(!(a <= b));
|
||||
BOOST_CHECK(a > b);
|
||||
BOOST_CHECK(a >= b);
|
||||
|
||||
BOOST_CHECK(!(a == b));
|
||||
BOOST_CHECK(a != b);
|
||||
|
||||
# ifdef __BORLANDC__
|
||||
::detail::ignore_unused_variable_warning(a);
|
||||
::detail::ignore_unused_variable_warning(b);
|
||||
# endif
|
||||
}
|
||||
|
||||
// comparisons between [1,2] and 2
|
||||
|
||||
static void test_12_2() {
|
||||
const I a(1,2);
|
||||
const int b = 2;
|
||||
|
||||
BOOST_CHECK(a < b);
|
||||
BOOST_CHECK(a <= b);
|
||||
BOOST_CHECK(!(a > b));
|
||||
BOOST_CHECK(!(a >= b));
|
||||
|
||||
BOOST_CHECK(!(a == b));
|
||||
BOOST_CHECK(a != b);
|
||||
|
||||
# ifdef __BORLANDC__
|
||||
::detail::ignore_unused_variable_warning(a);
|
||||
::detail::ignore_unused_variable_warning(b);
|
||||
# endif
|
||||
}
|
||||
|
||||
// comparisons between [1,2] and 3
|
||||
|
||||
static void test_12_3() {
|
||||
const I a(1,2);
|
||||
const int b = 3;
|
||||
|
||||
BOOST_CHECK(a < b);
|
||||
BOOST_CHECK(a <= b);
|
||||
BOOST_CHECK(!(a > b));
|
||||
BOOST_CHECK(!(a >= b));
|
||||
|
||||
BOOST_CHECK(!(a == b));
|
||||
BOOST_CHECK(a != b);
|
||||
|
||||
# ifdef __BORLANDC__
|
||||
::detail::ignore_unused_variable_warning(a);
|
||||
::detail::ignore_unused_variable_warning(b);
|
||||
# endif
|
||||
}
|
||||
|
||||
static void test_12_12() {
|
||||
const I a(1,2), b(1,2);
|
||||
|
||||
BOOST_CHECK(a == b);
|
||||
BOOST_CHECK(!(a != b));
|
||||
|
||||
# ifdef __BORLANDC__
|
||||
::detail::ignore_unused_variable_warning(a);
|
||||
::detail::ignore_unused_variable_warning(b);
|
||||
# endif
|
||||
}
|
||||
|
||||
static void test_11_11() {
|
||||
const I a(1,1), b(1,1);
|
||||
|
||||
BOOST_CHECK(a == b);
|
||||
BOOST_CHECK(!(a != b));
|
||||
|
||||
# ifdef __BORLANDC__
|
||||
::detail::ignore_unused_variable_warning(a);
|
||||
::detail::ignore_unused_variable_warning(b);
|
||||
# endif
|
||||
}
|
||||
|
||||
static void test_11_1() {
|
||||
const I a(1,1);
|
||||
const int b = 1;
|
||||
|
||||
BOOST_CHECK(a == b);
|
||||
BOOST_CHECK(!(a != b));
|
||||
|
||||
# ifdef __BORLANDC__
|
||||
::detail::ignore_unused_variable_warning(a);
|
||||
::detail::ignore_unused_variable_warning(b);
|
||||
# endif
|
||||
}
|
||||
|
||||
int test_main(int, char *[]) {
|
||||
test_12_34();
|
||||
test_13_24();
|
||||
test_12_23();
|
||||
test_12_0();
|
||||
test_12_1();
|
||||
test_12_2();
|
||||
test_12_3();
|
||||
test_12_12();
|
||||
test_11_11();
|
||||
test_11_1();
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,218 @@
|
||||
/* Boost test/cmp_set.cpp
|
||||
* test compare::set
|
||||
*
|
||||
* Copyright 2004 Guillaume Melquiond
|
||||
*
|
||||
* 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 "cmp_header.hpp"
|
||||
|
||||
using namespace boost::numeric::interval_lib::compare::set;
|
||||
|
||||
// comparisons between [1,2] and [3,4]
|
||||
|
||||
static void test_12_34() {
|
||||
const I a(1,2), b(3,4);
|
||||
|
||||
BOOST_CHECK(!(a < b));
|
||||
BOOST_CHECK(!(a <= b));
|
||||
BOOST_CHECK(!(a > b));
|
||||
BOOST_CHECK(!(a >= b));
|
||||
|
||||
BOOST_CHECK(!(b > a));
|
||||
BOOST_CHECK(!(b >= a));
|
||||
BOOST_CHECK(!(b < a));
|
||||
BOOST_CHECK(!(b <= a));
|
||||
|
||||
BOOST_CHECK(!(a == b));
|
||||
BOOST_CHECK(a != b);
|
||||
|
||||
# ifdef __BORLANDC__
|
||||
::detail::ignore_unused_variable_warning(a);
|
||||
::detail::ignore_unused_variable_warning(b);
|
||||
# endif
|
||||
}
|
||||
|
||||
// comparisons between [1,3] and [2,4]
|
||||
|
||||
static void test_13_24() {
|
||||
const I a(1,3), b(2,4);
|
||||
|
||||
BOOST_CHECK(!(a < b));
|
||||
BOOST_CHECK(!(a <= b));
|
||||
BOOST_CHECK(!(a > b));
|
||||
BOOST_CHECK(!(a >= b));
|
||||
|
||||
BOOST_CHECK(!(b < a));
|
||||
BOOST_CHECK(!(b <= a));
|
||||
BOOST_CHECK(!(b > a));
|
||||
BOOST_CHECK(!(b >= a));
|
||||
|
||||
BOOST_CHECK(!(a == b));
|
||||
BOOST_CHECK(a != b);
|
||||
|
||||
# ifdef __BORLANDC__
|
||||
::detail::ignore_unused_variable_warning(a);
|
||||
::detail::ignore_unused_variable_warning(b);
|
||||
# endif
|
||||
}
|
||||
|
||||
// comparisons between [1,4] and [2,3]
|
||||
|
||||
static void test_14_23() {
|
||||
const I a(1,4), b(2,3);
|
||||
|
||||
BOOST_CHECK(!(a < b));
|
||||
BOOST_CHECK(!(a <= b));
|
||||
BOOST_CHECK(a > b);
|
||||
BOOST_CHECK(a >= b);
|
||||
|
||||
BOOST_CHECK(b < a);
|
||||
BOOST_CHECK(b <= a);
|
||||
BOOST_CHECK(!(b > a));
|
||||
BOOST_CHECK(!(b >= a));
|
||||
|
||||
BOOST_CHECK(!(a == b));
|
||||
BOOST_CHECK(a != b);
|
||||
|
||||
# ifdef __BORLANDC__
|
||||
::detail::ignore_unused_variable_warning(a);
|
||||
::detail::ignore_unused_variable_warning(b);
|
||||
# endif
|
||||
}
|
||||
|
||||
// comparisons between [1,2] and [2,3]
|
||||
|
||||
static void test_12_23() {
|
||||
const I a(1,2), b(2,3);
|
||||
|
||||
BOOST_CHECK(!(a < b));
|
||||
BOOST_CHECK(!(a <= b));
|
||||
BOOST_CHECK(!(a > b));
|
||||
BOOST_CHECK(!(a >= b));
|
||||
|
||||
BOOST_CHECK(!(b < a));
|
||||
BOOST_CHECK(!(b <= a));
|
||||
BOOST_CHECK(!(b > a));
|
||||
BOOST_CHECK(!(b >= a));
|
||||
|
||||
BOOST_CHECK(!(a == b));
|
||||
BOOST_CHECK(a != b);
|
||||
|
||||
# ifdef __BORLANDC__
|
||||
::detail::ignore_unused_variable_warning(a);
|
||||
::detail::ignore_unused_variable_warning(b);
|
||||
# endif
|
||||
}
|
||||
|
||||
// comparisons between [1,2] and empty set
|
||||
|
||||
static void test_12_E() {
|
||||
I a(1, 2), b(I::empty());
|
||||
|
||||
BOOST_CHECK(!(a < b));
|
||||
BOOST_CHECK(!(a <= b));
|
||||
BOOST_CHECK(a > b);
|
||||
BOOST_CHECK(a >= b);
|
||||
|
||||
BOOST_CHECK(b < a);
|
||||
BOOST_CHECK(b <= a);
|
||||
BOOST_CHECK(!(b > a));
|
||||
BOOST_CHECK(!(b >= a));
|
||||
|
||||
BOOST_CHECK(!(a == b));
|
||||
BOOST_CHECK(a != b);
|
||||
|
||||
# ifdef __BORLANDC__
|
||||
::detail::ignore_unused_variable_warning(a);
|
||||
::detail::ignore_unused_variable_warning(b);
|
||||
# endif
|
||||
}
|
||||
|
||||
// comparisons between two empty sets
|
||||
|
||||
static void test_E_E() {
|
||||
I a(I::empty()), b(I::empty());
|
||||
|
||||
BOOST_CHECK(!(a < b));
|
||||
BOOST_CHECK(a <= b);
|
||||
BOOST_CHECK(!(a > b));
|
||||
BOOST_CHECK(a >= b);
|
||||
|
||||
BOOST_CHECK(!(b < a));
|
||||
BOOST_CHECK(b <= a);
|
||||
BOOST_CHECK(!(b > a));
|
||||
BOOST_CHECK(b >= a);
|
||||
|
||||
BOOST_CHECK(a == b);
|
||||
BOOST_CHECK(!(a != b));
|
||||
|
||||
# ifdef __BORLANDC__
|
||||
::detail::ignore_unused_variable_warning(a);
|
||||
::detail::ignore_unused_variable_warning(b);
|
||||
# endif
|
||||
}
|
||||
|
||||
// comparisons between [1,2] and [1,2]
|
||||
|
||||
static void test_12_12() {
|
||||
const I a(1,2), b(1,2);
|
||||
|
||||
BOOST_CHECK(!(a < b));
|
||||
BOOST_CHECK(a <= b);
|
||||
BOOST_CHECK(!(a > b));
|
||||
BOOST_CHECK(a >= b);
|
||||
|
||||
BOOST_CHECK(!(b < a));
|
||||
BOOST_CHECK(b <= a);
|
||||
BOOST_CHECK(!(b > a));
|
||||
BOOST_CHECK(b >= a);
|
||||
|
||||
BOOST_CHECK(a == b);
|
||||
BOOST_CHECK(!(a != b));
|
||||
|
||||
# ifdef __BORLANDC__
|
||||
::detail::ignore_unused_variable_warning(a);
|
||||
::detail::ignore_unused_variable_warning(b);
|
||||
# endif
|
||||
}
|
||||
|
||||
// comparisons between [1,1] and [1,1]
|
||||
|
||||
static void test_11_11() {
|
||||
const I a(1,1), b(1,1);
|
||||
|
||||
BOOST_CHECK(!(a < b));
|
||||
BOOST_CHECK(a <= b);
|
||||
BOOST_CHECK(!(a > b));
|
||||
BOOST_CHECK(a >= b);
|
||||
|
||||
BOOST_CHECK(!(b < a));
|
||||
BOOST_CHECK(b <= a);
|
||||
BOOST_CHECK(!(b > a));
|
||||
BOOST_CHECK(b >= a);
|
||||
|
||||
BOOST_CHECK(a == b);
|
||||
BOOST_CHECK(!(a != b));
|
||||
|
||||
# ifdef __BORLANDC__
|
||||
::detail::ignore_unused_variable_warning(a);
|
||||
::detail::ignore_unused_variable_warning(b);
|
||||
# endif
|
||||
}
|
||||
|
||||
int test_main(int, char *[]) {
|
||||
test_12_34();
|
||||
test_13_24();
|
||||
test_14_23();
|
||||
test_12_23();
|
||||
test_12_E();
|
||||
test_E_E();
|
||||
test_12_12();
|
||||
test_11_11();
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,224 @@
|
||||
/* Boost test/cmp_tribool.cpp
|
||||
* test compare::tribool
|
||||
*
|
||||
* Copyright 2004 Guillaume Melquiond
|
||||
*
|
||||
* 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 "cmp_header.hpp"
|
||||
#include <boost/numeric/interval/compare/tribool.hpp>
|
||||
|
||||
using namespace boost::numeric::interval_lib::compare::tribool;
|
||||
|
||||
// comparisons between [1,2] and [3,4]
|
||||
|
||||
static void test_12_34() {
|
||||
const I a(1,2), b(3,4);
|
||||
|
||||
BOOST_CHECK(a < b);
|
||||
BOOST_CHECK(a <= b);
|
||||
BOOST_CHECK(!(a > b));
|
||||
BOOST_CHECK(!(a >= b));
|
||||
|
||||
BOOST_CHECK(b > a);
|
||||
BOOST_CHECK(b >= a);
|
||||
BOOST_CHECK(!(b < a));
|
||||
BOOST_CHECK(!(b <= a));
|
||||
|
||||
BOOST_CHECK(!(a == b));
|
||||
BOOST_CHECK(a != b);
|
||||
|
||||
# ifdef __BORLANDC__
|
||||
::detail::ignore_unused_variable_warning(a);
|
||||
::detail::ignore_unused_variable_warning(b);
|
||||
# endif
|
||||
}
|
||||
|
||||
// comparisons between [1,3] and [2,4]
|
||||
|
||||
static void test_13_24() {
|
||||
const I a(1,3), b(2,4);
|
||||
|
||||
BOOST_CHECK(indeterminate(a < b));
|
||||
BOOST_CHECK(indeterminate(a <= b));
|
||||
BOOST_CHECK(indeterminate(a > b));
|
||||
BOOST_CHECK(indeterminate(a >= b));
|
||||
|
||||
BOOST_CHECK(indeterminate(b < a));
|
||||
BOOST_CHECK(indeterminate(b <= a));
|
||||
BOOST_CHECK(indeterminate(b > a));
|
||||
BOOST_CHECK(indeterminate(b >= a));
|
||||
|
||||
BOOST_CHECK(indeterminate(a == b));
|
||||
BOOST_CHECK(indeterminate(a != b));
|
||||
|
||||
# ifdef __BORLANDC__
|
||||
::detail::ignore_unused_variable_warning(a);
|
||||
::detail::ignore_unused_variable_warning(b);
|
||||
# endif
|
||||
}
|
||||
|
||||
// comparisons between [1,2] and [2,3]
|
||||
|
||||
static void test_12_23() {
|
||||
const I a(1,2), b(2,3);
|
||||
|
||||
BOOST_CHECK(indeterminate(a < b));
|
||||
BOOST_CHECK(a <= b);
|
||||
BOOST_CHECK(!(a > b));
|
||||
BOOST_CHECK(indeterminate(a >= b));
|
||||
|
||||
BOOST_CHECK(!(b < a));
|
||||
BOOST_CHECK(indeterminate(b <= a));
|
||||
BOOST_CHECK(indeterminate(b > a));
|
||||
BOOST_CHECK(b >= a);
|
||||
|
||||
BOOST_CHECK(indeterminate(a == b));
|
||||
BOOST_CHECK(indeterminate(a != b));
|
||||
|
||||
# ifdef __BORLANDC__
|
||||
::detail::ignore_unused_variable_warning(a);
|
||||
::detail::ignore_unused_variable_warning(b);
|
||||
# endif
|
||||
}
|
||||
|
||||
// comparisons between [1,2] and 0
|
||||
|
||||
static void test_12_0() {
|
||||
const I a(1,2);
|
||||
const int b = 0;
|
||||
|
||||
BOOST_CHECK(!(a < b));
|
||||
BOOST_CHECK(!(a <= b));
|
||||
BOOST_CHECK(a > b);
|
||||
BOOST_CHECK(a >= b);
|
||||
|
||||
BOOST_CHECK(!(a == b));
|
||||
BOOST_CHECK(a != b);
|
||||
|
||||
# ifdef __BORLANDC__
|
||||
::detail::ignore_unused_variable_warning(a);
|
||||
::detail::ignore_unused_variable_warning(b);
|
||||
# endif
|
||||
}
|
||||
|
||||
// comparisons between [1,2] and 1
|
||||
|
||||
static void test_12_1() {
|
||||
const I a(1,2);
|
||||
const int b = 1;
|
||||
|
||||
BOOST_CHECK(!(a < b));
|
||||
BOOST_CHECK(indeterminate(a <= b));
|
||||
BOOST_CHECK(indeterminate(a > b));
|
||||
BOOST_CHECK(a >= b);
|
||||
|
||||
BOOST_CHECK(indeterminate(a == b));
|
||||
BOOST_CHECK(indeterminate(a != b));
|
||||
|
||||
# ifdef __BORLANDC__
|
||||
::detail::ignore_unused_variable_warning(a);
|
||||
::detail::ignore_unused_variable_warning(b);
|
||||
# endif
|
||||
}
|
||||
|
||||
// comparisons between [1,2] and 2
|
||||
|
||||
static void test_12_2() {
|
||||
const I a(1,2);
|
||||
const int b = 2;
|
||||
|
||||
BOOST_CHECK(indeterminate(a < b));
|
||||
BOOST_CHECK(a <= b);
|
||||
BOOST_CHECK(!(a > b));
|
||||
BOOST_CHECK(indeterminate(a >= b));
|
||||
|
||||
BOOST_CHECK(indeterminate(a == b));
|
||||
BOOST_CHECK(indeterminate(a != b));
|
||||
|
||||
# ifdef __BORLANDC__
|
||||
::detail::ignore_unused_variable_warning(a);
|
||||
::detail::ignore_unused_variable_warning(b);
|
||||
# endif
|
||||
}
|
||||
|
||||
// comparisons between [1,2] and 3
|
||||
|
||||
static void test_12_3() {
|
||||
const I a(1,2);
|
||||
const int b = 3;
|
||||
|
||||
BOOST_CHECK(a < b);
|
||||
BOOST_CHECK(a <= b);
|
||||
BOOST_CHECK(!(a > b));
|
||||
BOOST_CHECK(!(a >= b));
|
||||
|
||||
BOOST_CHECK(!(a == b));
|
||||
BOOST_CHECK(a != b);
|
||||
|
||||
# ifdef __BORLANDC__
|
||||
::detail::ignore_unused_variable_warning(a);
|
||||
::detail::ignore_unused_variable_warning(b);
|
||||
# endif
|
||||
}
|
||||
|
||||
// comparisons between [1,2] and [1,2]
|
||||
|
||||
static void test_12_12() {
|
||||
const I a(1,2), b(1,2);
|
||||
|
||||
BOOST_CHECK(indeterminate(a == b));
|
||||
BOOST_CHECK(indeterminate(a != b));
|
||||
|
||||
# ifdef __BORLANDC__
|
||||
::detail::ignore_unused_variable_warning(a);
|
||||
::detail::ignore_unused_variable_warning(b);
|
||||
# endif
|
||||
}
|
||||
|
||||
// comparisons between [1,1] and [1,1]
|
||||
|
||||
static void test_11_11() {
|
||||
const I a(1,1), b(1,1);
|
||||
|
||||
BOOST_CHECK(a == b);
|
||||
BOOST_CHECK(!(a != b));
|
||||
|
||||
# ifdef __BORLANDC__
|
||||
::detail::ignore_unused_variable_warning(a);
|
||||
::detail::ignore_unused_variable_warning(b);
|
||||
# endif
|
||||
}
|
||||
|
||||
// comparisons between [1,1] and 1
|
||||
|
||||
static void test_11_1() {
|
||||
const I a(1,1);
|
||||
const int b = 1;
|
||||
|
||||
BOOST_CHECK(a == b);
|
||||
BOOST_CHECK(!(a != b));
|
||||
|
||||
# ifdef __BORLANDC__
|
||||
::detail::ignore_unused_variable_warning(a);
|
||||
::detail::ignore_unused_variable_warning(b);
|
||||
# endif
|
||||
}
|
||||
|
||||
int test_main(int, char *[]) {
|
||||
test_12_34();
|
||||
test_13_24();
|
||||
test_12_23();
|
||||
test_12_0();
|
||||
test_12_1();
|
||||
test_12_2();
|
||||
test_12_3();
|
||||
test_12_12();
|
||||
test_11_11();
|
||||
test_11_1();
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
/* Boost test/det.cpp
|
||||
* test protected and unprotected rounding on an unstable determinant
|
||||
*
|
||||
* Copyright 2002-2003 Guillaume Melquiond
|
||||
*
|
||||
* 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 <boost/numeric/interval.hpp>
|
||||
#include <boost/test/minimal.hpp>
|
||||
#include "bugs.hpp"
|
||||
|
||||
#define size 8
|
||||
|
||||
template<class I>
|
||||
void det(I (&mat)[size][size]) {
|
||||
for(int i = 0; i < size; i++)
|
||||
for(int j = 0; j < size; j++)
|
||||
mat[i][j] = I(1) / I(i + j + 1);
|
||||
|
||||
for(int i = 0; i < size - 1; i++) {
|
||||
int m = i, n = i;
|
||||
typename I::base_type v = 0;
|
||||
for(int a = i; a < size; a++)
|
||||
for(int b = i; b < size; b++) {
|
||||
typename I::base_type w = abs(mat[a][b]).lower();
|
||||
if (w > v) { m = a; n = b; v = w; }
|
||||
}
|
||||
if (n != i)
|
||||
for(int a = 0; a < size; a++) {
|
||||
I t = mat[a][n];
|
||||
mat[a][n] = mat[a][i];
|
||||
mat[a][i] = t;
|
||||
}
|
||||
if (m != i)
|
||||
for(int b = i; b < size; b++) {
|
||||
I t = mat[m][b];
|
||||
mat[m][b] = mat[m][i];
|
||||
mat[m][i] = t;
|
||||
}
|
||||
if (((m + n) & 1) == 1) { };
|
||||
I c = mat[i][i];
|
||||
for(int j = i + 1; j < size; j++) {
|
||||
I f = mat[j][i] / c;
|
||||
for(int k = i; k < size; k++)
|
||||
mat[j][k] -= f * mat[i][k];
|
||||
}
|
||||
if (zero_in(c)) return;
|
||||
}
|
||||
}
|
||||
|
||||
namespace my_namespace {
|
||||
|
||||
using namespace boost;
|
||||
using namespace numeric;
|
||||
using namespace interval_lib;
|
||||
|
||||
template<class T>
|
||||
struct variants {
|
||||
typedef interval<T> I_op;
|
||||
typedef typename change_rounding<I_op, save_state<rounded_arith_std<T> > >::type I_sp;
|
||||
typedef typename unprotect<I_op>::type I_ou;
|
||||
typedef typename unprotect<I_sp>::type I_su;
|
||||
typedef T type;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
template<class T>
|
||||
bool test() {
|
||||
typedef my_namespace::variants<double> types;
|
||||
types::I_op mat_op[size][size];
|
||||
types::I_sp mat_sp[size][size];
|
||||
types::I_ou mat_ou[size][size];
|
||||
types::I_su mat_su[size][size];
|
||||
det(mat_op);
|
||||
det(mat_sp);
|
||||
{ types::I_op::traits_type::rounding rnd; det(mat_ou); }
|
||||
{ types::I_sp::traits_type::rounding rnd; det(mat_su); }
|
||||
for(int i = 0; i < size; i++)
|
||||
for(int j = 0; j < size; j++) {
|
||||
typedef types::I_op I;
|
||||
I d_op = mat_op[i][j];
|
||||
I d_sp = mat_sp[i][j];
|
||||
I d_ou = mat_ou[i][j];
|
||||
I d_su = mat_su[i][j];
|
||||
if (!(equal(d_op, d_sp) && equal(d_sp, d_ou) && equal(d_ou, d_su)))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
int test_main(int, char *[]) {
|
||||
BOOST_CHECK(test<float>());
|
||||
BOOST_CHECK(test<double>());
|
||||
BOOST_CHECK(test<long double>());
|
||||
# ifdef __BORLANDC__
|
||||
::detail::ignore_warnings();
|
||||
# endif
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
/* Boost test/fmod.cpp
|
||||
* test the fmod with specially crafted integer intervals
|
||||
*
|
||||
* Copyright 2002-2003 Guillaume Melquiond
|
||||
*
|
||||
* 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 <boost/numeric/interval/interval.hpp>
|
||||
#include <boost/numeric/interval/arith.hpp>
|
||||
#include <boost/numeric/interval/arith2.hpp>
|
||||
#include <boost/numeric/interval/utility.hpp>
|
||||
#include <boost/numeric/interval/checking.hpp>
|
||||
#include <boost/numeric/interval/rounding.hpp>
|
||||
#include <boost/test/minimal.hpp>
|
||||
#include "bugs.hpp"
|
||||
|
||||
struct my_rounded_arith {
|
||||
int sub_down(int x, int y) { return x - y; }
|
||||
int sub_up (int x, int y) { return x - y; }
|
||||
int mul_down(int x, int y) { return x * y; }
|
||||
int mul_up (int x, int y) { return x * y; }
|
||||
int div_down(int x, int y) {
|
||||
int q = x / y;
|
||||
return (x % y < 0) ? (q - 1) : q;
|
||||
}
|
||||
int int_down(int x) { return x; }
|
||||
};
|
||||
|
||||
using namespace boost;
|
||||
using namespace numeric;
|
||||
using namespace interval_lib;
|
||||
|
||||
typedef change_rounding<interval<int>, save_state_nothing<my_rounded_arith> >::type I;
|
||||
|
||||
int test_main(int, char *[]) {
|
||||
|
||||
BOOST_CHECK(equal(fmod(I(6,9), 7), I(6,9)));
|
||||
BOOST_CHECK(equal(fmod(6, I(7,8)), I(6,6)));
|
||||
BOOST_CHECK(equal(fmod(I(6,9), I(7,8)), I(6,9)));
|
||||
|
||||
BOOST_CHECK(equal(fmod(I(13,17), 7), I(6,10)));
|
||||
BOOST_CHECK(equal(fmod(13, I(7,8)), I(5,6)));
|
||||
BOOST_CHECK(equal(fmod(I(13,17), I(7,8)), I(5,10)));
|
||||
|
||||
BOOST_CHECK(equal(fmod(I(-17,-13), 7), I(4,8)));
|
||||
BOOST_CHECK(equal(fmod(-17, I(7,8)), I(4,7)));
|
||||
BOOST_CHECK(equal(fmod(I(-17,-13), I(7,8)), I(4,11)));
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
/* Boost test/integer.cpp
|
||||
* test int extension
|
||||
*
|
||||
* Copyright 2003 Guillaume Melquiond
|
||||
*
|
||||
* 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 <boost/numeric/interval.hpp>
|
||||
#include <boost/numeric/interval/ext/integer.hpp>
|
||||
#include "bugs.hpp"
|
||||
|
||||
typedef boost::numeric::interval<float> I;
|
||||
|
||||
int main() {
|
||||
I x, y;
|
||||
x = 4 - (2 * y + 1) / 3;
|
||||
# ifdef __BORLANDC__
|
||||
::detail::ignore_warnings();
|
||||
# endif
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
/* Boost test/msvc_x64_flags.cpp
|
||||
* Test for amd64\ieee.c(102) : Assertion failed: (mask&~(_MCW_DN|_MCW_EM|_MCW_RC))==0.
|
||||
* This happens with MSVC on x64 in Debug mode. See ticket #4964.
|
||||
*
|
||||
* 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 <boost/numeric/interval.hpp>
|
||||
#include <boost/test/minimal.hpp>
|
||||
#include "bugs.hpp"
|
||||
|
||||
int test_main(int, char *[]) {
|
||||
boost::numeric::interval<double> i(0.0, 0.0);
|
||||
boost::numeric::interval<double> i2 = 60.0 - i;
|
||||
# ifdef __BORLANDC__
|
||||
::detail::ignore_warnings();
|
||||
# endif
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
/* Boost test/mul.cpp
|
||||
* test multiplication, division, square and square root on some intervals
|
||||
*
|
||||
* Copyright 2002-2003 Guillaume Melquiond
|
||||
*
|
||||
* 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 <boost/numeric/interval.hpp>
|
||||
#include <boost/test/minimal.hpp>
|
||||
#include "bugs.hpp"
|
||||
|
||||
typedef boost::numeric::interval<double> I;
|
||||
|
||||
static double min BOOST_PREVENT_MACRO_SUBSTITUTION (double a, double b, double c, double d) {
|
||||
return (std::min)((std::min)(a, b), (std::min)(c, d));
|
||||
}
|
||||
|
||||
static double max BOOST_PREVENT_MACRO_SUBSTITUTION (double a, double b, double c, double d) {
|
||||
return (std::max)((std::max)(a, b), (std::max)(c, d));
|
||||
}
|
||||
|
||||
static bool test_mul(double al, double au, double bl, double bu) {
|
||||
I a(al, au), b(bl, bu);
|
||||
I c = a * b;
|
||||
return c.lower() == (min)(al*bl, al*bu, au*bl, au*bu)
|
||||
&& c.upper() == (max)(al*bl, al*bu, au*bl, au*bu);
|
||||
}
|
||||
|
||||
static bool test_mul1(double ac, double bl, double bu) {
|
||||
I a(ac), b(bl, bu);
|
||||
I c = ac * b;
|
||||
I d = b * ac;
|
||||
I e = a * b;
|
||||
return equal(c, d) && equal(d, e);
|
||||
}
|
||||
|
||||
static bool test_div(double al, double au, double bl, double bu) {
|
||||
I a(al, au), b(bl, bu);
|
||||
I c = a / b;
|
||||
return c.lower() == (min)(al/bl, al/bu, au/bl, au/bu)
|
||||
&& c.upper() == (max)(al/bl, al/bu, au/bl, au/bu);
|
||||
}
|
||||
|
||||
static bool test_div1(double al, double au, double bc) {
|
||||
I a(al, au), b(bc);
|
||||
I c = a / bc;
|
||||
I d = a / b;
|
||||
return equal(c, d);
|
||||
}
|
||||
|
||||
static bool test_div2(double ac, double bl, double bu) {
|
||||
I a(ac), b(bl, bu);
|
||||
I c = ac / b;
|
||||
I d = a / b;
|
||||
return equal(c, d);
|
||||
}
|
||||
|
||||
static bool test_square(double al, double au) {
|
||||
I a(al, au);
|
||||
I b = square(a);
|
||||
I c = a * a;
|
||||
return b.upper() == c.upper() &&
|
||||
(b.lower() == c.lower() || (c.lower() <= 0 && b.lower() == 0));
|
||||
}
|
||||
|
||||
static bool test_sqrt(double al, double au) {
|
||||
I a(al, au);
|
||||
I b = square(sqrt(a));
|
||||
return subset(abs(a), b);
|
||||
}
|
||||
|
||||
int test_main(int, char*[]) {
|
||||
BOOST_CHECK(test_mul(2, 3, 5, 7));
|
||||
BOOST_CHECK(test_mul(2, 3, -5, 7));
|
||||
BOOST_CHECK(test_mul(2, 3, -7, -5));
|
||||
BOOST_CHECK(test_mul(-2, 3, 5, 7));
|
||||
BOOST_CHECK(test_mul(-2, 3, -5, 7));
|
||||
BOOST_CHECK(test_mul(-2, 3, -7, -5));
|
||||
BOOST_CHECK(test_mul(-3, -2, 5, 7));
|
||||
BOOST_CHECK(test_mul(-3, -2, -5, 7));
|
||||
BOOST_CHECK(test_mul(-3, -2, -7, -5));
|
||||
|
||||
BOOST_CHECK(test_mul1(3, 5, 7));
|
||||
BOOST_CHECK(test_mul1(3, -5, 7));
|
||||
BOOST_CHECK(test_mul1(3, -7, -5));
|
||||
BOOST_CHECK(test_mul1(-3, 5, 7));
|
||||
BOOST_CHECK(test_mul1(-3, -5, 7));
|
||||
BOOST_CHECK(test_mul1(-3, -7, -5));
|
||||
|
||||
BOOST_CHECK(test_div(30, 42, 2, 3));
|
||||
BOOST_CHECK(test_div(30, 42, -3, -2));
|
||||
BOOST_CHECK(test_div(-30, 42, 2, 3));
|
||||
BOOST_CHECK(test_div(-30, 42, -3, -2));
|
||||
BOOST_CHECK(test_div(-42, -30, 2, 3));
|
||||
BOOST_CHECK(test_div(-42, -30, -3, -2));
|
||||
|
||||
BOOST_CHECK(test_div1(30, 42, 3));
|
||||
BOOST_CHECK(test_div1(30, 42, -3));
|
||||
BOOST_CHECK(test_div1(-30, 42, 3));
|
||||
BOOST_CHECK(test_div1(-30, 42, -3));
|
||||
BOOST_CHECK(test_div1(-42, -30, 3));
|
||||
BOOST_CHECK(test_div1(-42, -30, -3));
|
||||
|
||||
BOOST_CHECK(test_div2(30, 2, 3));
|
||||
BOOST_CHECK(test_div2(30, -3, -2));
|
||||
BOOST_CHECK(test_div2(-30, 2, 3));
|
||||
BOOST_CHECK(test_div2(-30, -3, -2));
|
||||
|
||||
BOOST_CHECK(test_square(2, 3));
|
||||
BOOST_CHECK(test_square(-2, 3));
|
||||
BOOST_CHECK(test_square(-3, 2));
|
||||
|
||||
BOOST_CHECK(test_sqrt(2, 3));
|
||||
BOOST_CHECK(test_sqrt(5, 7));
|
||||
BOOST_CHECK(test_sqrt(-1, 2));
|
||||
|
||||
# ifdef __BORLANDC__
|
||||
::detail::ignore_warnings();
|
||||
# endif
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/* Boost test/overflow.cpp
|
||||
* test if extended precision exponent does not disturb interval computation
|
||||
*
|
||||
* Copyright 2002-2003 Guillaume Melquiond
|
||||
*
|
||||
* 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 <boost/numeric/interval.hpp>
|
||||
#include <boost/test/minimal.hpp>
|
||||
#include "bugs.hpp"
|
||||
|
||||
template<class I>
|
||||
void test_one(typename I::base_type x, typename I::base_type f) {
|
||||
I y = x;
|
||||
typename I::base_type g = 1 / f;
|
||||
const int nb = 10000;
|
||||
for(int i = 0; i < nb; i++) y *= f;
|
||||
for(int i = 0; i < nb; i++) y *= g;
|
||||
BOOST_CHECK(in(x, y));
|
||||
# ifdef __BORLANDC__
|
||||
::detail::ignore_unused_variable_warning(nb);
|
||||
# endif
|
||||
}
|
||||
|
||||
template<class I>
|
||||
void test() {
|
||||
test_one<I>(1., 25.);
|
||||
test_one<I>(1., 0.04);
|
||||
test_one<I>(-1., 25.);
|
||||
test_one<I>(-1., 0.04);
|
||||
}
|
||||
|
||||
int test_main(int, char *[]) {
|
||||
test<boost::numeric::interval<float> >();
|
||||
test<boost::numeric::interval<double> >();
|
||||
//test<boost::numeric::interval<long double> >();
|
||||
# ifdef __BORLANDC__
|
||||
::detail::ignore_warnings();
|
||||
# endif
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
/* Boost test/pi.cpp
|
||||
* test if the pi constant is correctly defined
|
||||
*
|
||||
* Copyright 2002-2003 Guillaume Melquiond, Sylvain Pion
|
||||
*
|
||||
* 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 <boost/numeric/interval.hpp>
|
||||
#include <boost/limits.hpp>
|
||||
#include <boost/test/minimal.hpp>
|
||||
#include "bugs.hpp"
|
||||
|
||||
#define PI 3.14159265358979323846
|
||||
|
||||
typedef boost::numeric::interval<int> I_i;
|
||||
typedef boost::numeric::interval<float> I_f;
|
||||
typedef boost::numeric::interval<double> I_d;
|
||||
typedef boost::numeric::interval<long double> I_ld;
|
||||
|
||||
using boost::numeric::interval_lib::pi;
|
||||
using boost::numeric::interval_lib::pi_half;
|
||||
using boost::numeric::interval_lib::pi_twice;
|
||||
|
||||
int test_main(int, char *[]) {
|
||||
I_i pi_i = pi<I_i>();
|
||||
I_f pi_f = pi<I_f>();
|
||||
I_d pi_d = pi<I_d>();
|
||||
I_ld pi_ld = pi<I_ld>();
|
||||
|
||||
BOOST_CHECK(in((int) PI, pi_i));
|
||||
BOOST_CHECK(in((float) PI, pi_f));
|
||||
BOOST_CHECK(in((double)PI, pi_d));
|
||||
BOOST_CHECK(subset(pi_i, widen(I_i((int) PI), 1)));
|
||||
BOOST_CHECK(subset(pi_f, widen(I_f((float) PI), (std::numeric_limits<float> ::min)())));
|
||||
BOOST_CHECK(subset(pi_d, widen(I_d((double)PI), (std::numeric_limits<double>::min)())));
|
||||
|
||||
// We can't test the following equalities for interval<int>.
|
||||
I_f pi_f_half = pi_half<I_f>();
|
||||
I_f pi_f_twice = pi_twice<I_f>();
|
||||
|
||||
I_d pi_d_half = pi_half<I_d>();
|
||||
I_d pi_d_twice = pi_twice<I_d>();
|
||||
|
||||
I_ld pi_ld_half = pi_half<I_ld>();
|
||||
I_ld pi_ld_twice = pi_twice<I_ld>();
|
||||
|
||||
BOOST_CHECK(equal(2.0f * pi_f_half, pi_f));
|
||||
BOOST_CHECK(equal(2.0 * pi_d_half, pi_d));
|
||||
BOOST_CHECK(equal(2.0l * pi_ld_half, pi_ld));
|
||||
|
||||
BOOST_CHECK(equal(2.0f * pi_f, pi_f_twice));
|
||||
BOOST_CHECK(equal(2.0 * pi_d, pi_d_twice));
|
||||
BOOST_CHECK(equal(2.0l * pi_ld, pi_ld_twice));
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
/* Boost test/pow.cpp
|
||||
* test the pow function
|
||||
*
|
||||
* Copyright 2002-2003 Guillaume Melquiond
|
||||
*
|
||||
* 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 <boost/numeric/interval.hpp>
|
||||
#include <boost/test/minimal.hpp>
|
||||
#include "bugs.hpp"
|
||||
|
||||
bool test_pow(double al, double au, double bl, double bu, int p) {
|
||||
typedef boost::numeric::interval<double> I;
|
||||
I b = pow(I(al, au), p);
|
||||
return b.lower() == bl && b.upper() == bu;
|
||||
}
|
||||
|
||||
int test_main(int, char *[]) {
|
||||
BOOST_CHECK(test_pow(2, 3, 8, 27, 3));
|
||||
BOOST_CHECK(test_pow(2, 3, 16, 81, 4));
|
||||
BOOST_CHECK(test_pow(-3, 2, -27, 8, 3));
|
||||
BOOST_CHECK(test_pow(-3, 2, 0, 81, 4));
|
||||
BOOST_CHECK(test_pow(-3, -2, -27, -8, 3));
|
||||
BOOST_CHECK(test_pow(-3, -2, 16, 81, 4));
|
||||
|
||||
BOOST_CHECK(test_pow(2, 4, 1./64, 1./8, -3));
|
||||
BOOST_CHECK(test_pow(2, 4, 1./256, 1./16, -4));
|
||||
BOOST_CHECK(test_pow(-4, -2, -1./8, -1./64, -3));
|
||||
BOOST_CHECK(test_pow(-4, -2, 1./256, 1./16, -4));
|
||||
|
||||
BOOST_CHECK(test_pow(2, 3, 1, 1, 0));
|
||||
BOOST_CHECK(test_pow(-3, 2, 1, 1, 0));
|
||||
BOOST_CHECK(test_pow(-3, -2, 1, 1, 0));
|
||||
|
||||
# ifdef __BORLANDC__
|
||||
::detail::ignore_warnings();
|
||||
# endif
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
/* Boost test/test_float.cpp
|
||||
* test arithmetic operations on a range of intervals
|
||||
*
|
||||
* Copyright 2003 Guillaume Melquiond
|
||||
*
|
||||
* 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 <boost/numeric/interval.hpp>
|
||||
#include <boost/test/test_tools.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include "bugs.hpp"
|
||||
|
||||
/* All the following tests should be BOOST_CHECK; however, if a test fails,
|
||||
the probability is high that hundreds of other tests will fail, so it is
|
||||
replaced by BOOST_REQUIRE to avoid flooding the logs. */
|
||||
|
||||
template<class T, class F>
|
||||
void test_unary() {
|
||||
typedef typename F::I I;
|
||||
for(I a(-10., -9.91); a.lower() <= 10.; a += 0.3) {
|
||||
if (!F::validate(a)) continue;
|
||||
I rI = F::f_I(a);
|
||||
T rT1 = F::f_T(a.lower()), rT2 = F::f_T(a.upper()),
|
||||
rT3 = F::f_T(median(a));
|
||||
BOOST_REQUIRE(in(rT1, rI));
|
||||
BOOST_REQUIRE(in(rT2, rI));
|
||||
BOOST_REQUIRE(in(rT3, rI));
|
||||
}
|
||||
}
|
||||
|
||||
template<class T, class F>
|
||||
void test_binary() {
|
||||
typedef typename F::I I;
|
||||
for(I a(-10., -9.91); a.lower() <= 10.; a += 0.3) {
|
||||
for(I b(-10., -9.91); b.lower() <= 10.; b += 0.3) {
|
||||
if (!F::validate(a, b)) continue;
|
||||
T al = a.lower(), au = a.upper(), bl = b.lower(), bu = b.upper();
|
||||
I rII = F::f_II(a, b);
|
||||
I rIT1 = F::f_IT(a, bl), rIT2 = F::f_IT(a, bu);
|
||||
I rTI1 = F::f_TI(al, b), rTI2 = F::f_TI(au, b);
|
||||
I rTT1 = F::f_TT(al, bl), rTT2 = F::f_TT(al, bu);
|
||||
I rTT3 = F::f_TT(au, bl), rTT4 = F::f_TT(au, bu);
|
||||
BOOST_REQUIRE(subset(rTT1, rIT1));
|
||||
BOOST_REQUIRE(subset(rTT3, rIT1));
|
||||
BOOST_REQUIRE(subset(rTT2, rIT2));
|
||||
BOOST_REQUIRE(subset(rTT4, rIT2));
|
||||
BOOST_REQUIRE(subset(rTT1, rTI1));
|
||||
BOOST_REQUIRE(subset(rTT2, rTI1));
|
||||
BOOST_REQUIRE(subset(rTT3, rTI2));
|
||||
BOOST_REQUIRE(subset(rTT4, rTI2));
|
||||
BOOST_REQUIRE(subset(rIT1, rII));
|
||||
BOOST_REQUIRE(subset(rIT2, rII));
|
||||
BOOST_REQUIRE(subset(rTI1, rII));
|
||||
BOOST_REQUIRE(subset(rTI2, rII));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#define new_unary_bunch(name, op, val) \
|
||||
template<class T> \
|
||||
struct name { \
|
||||
typedef boost::numeric::interval<T> I; \
|
||||
static I f_I(const I& a) { return op(a); } \
|
||||
static T f_T(const T& a) { return op(a); } \
|
||||
static bool validate(const I& a) { return val; } \
|
||||
}
|
||||
|
||||
//#ifndef BOOST_NO_STDC_NAMESPACE
|
||||
using std::abs;
|
||||
using std::sqrt;
|
||||
//#endif
|
||||
|
||||
new_unary_bunch(bunch_pos, +, true);
|
||||
new_unary_bunch(bunch_neg, -, true);
|
||||
new_unary_bunch(bunch_sqrt, sqrt, a.lower() >= 0.);
|
||||
new_unary_bunch(bunch_abs, abs, true);
|
||||
|
||||
template<class T>
|
||||
void test_all_unaries() {
|
||||
BOOST_TEST_CHECKPOINT("pos"); test_unary<T, bunch_pos<T> >();
|
||||
BOOST_TEST_CHECKPOINT("neg"); test_unary<T, bunch_neg<T> >();
|
||||
BOOST_TEST_CHECKPOINT("sqrt"); test_unary<T, bunch_sqrt<T> >();
|
||||
BOOST_TEST_CHECKPOINT("abs"); test_unary<T, bunch_abs<T> >();
|
||||
}
|
||||
|
||||
#define new_binary_bunch(name, op, val) \
|
||||
template<class T> \
|
||||
struct bunch_##name { \
|
||||
typedef boost::numeric::interval<T> I; \
|
||||
static I f_II(const I& a, const I& b) { return a op b; } \
|
||||
static I f_IT(const I& a, const T& b) { return a op b; } \
|
||||
static I f_TI(const T& a, const I& b) { return a op b; } \
|
||||
static I f_TT(const T& a, const T& b) \
|
||||
{ return boost::numeric::interval_lib::name<I>(a,b); } \
|
||||
static bool validate(const I& a, const I& b) { return val; } \
|
||||
}
|
||||
|
||||
new_binary_bunch(add, +, true);
|
||||
new_binary_bunch(sub, -, true);
|
||||
new_binary_bunch(mul, *, true);
|
||||
new_binary_bunch(div, /, !zero_in(b));
|
||||
|
||||
template<class T>
|
||||
void test_all_binaries() {
|
||||
BOOST_TEST_CHECKPOINT("add"); test_binary<T, bunch_add<T> >();
|
||||
BOOST_TEST_CHECKPOINT("sub"); test_binary<T, bunch_sub<T> >();
|
||||
BOOST_TEST_CHECKPOINT("mul"); test_binary<T, bunch_mul<T> >();
|
||||
BOOST_TEST_CHECKPOINT("div"); test_binary<T, bunch_div<T> >();
|
||||
}
|
||||
|
||||
int test_main(int, char *[]) {
|
||||
BOOST_TEST_CHECKPOINT("float tests");
|
||||
test_all_unaries<float> ();
|
||||
test_all_binaries<float> ();
|
||||
BOOST_TEST_CHECKPOINT("double tests");
|
||||
test_all_unaries<double>();
|
||||
test_all_binaries<double>();
|
||||
//BOOST_TEST_CHECKPOINT("long double tests");
|
||||
//test_all_unaries<long double>();
|
||||
//test_all_binaries<long double>();
|
||||
# ifdef __BORLANDC__
|
||||
::detail::ignore_warnings();
|
||||
# endif
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user