Use lightweight tests to avoid Boost.Test warnings, RTTI issues and minimize compilation times

This commit is contained in:
Antony Polukhin
2015-06-21 23:16:46 +03:00
parent c0f75c27fa
commit d7ec25e56b
12 changed files with 175 additions and 183 deletions

View File

@ -14,13 +14,14 @@
#include <boost/unordered_set.hpp>
#include <boost/functional/hash.hpp>
//<-
// Making `#include <cassert>` visible in docs, while actually using hand-made check
// Making `#include <cassert>` visible in docs, while actually using `BOOST_TEST`
// instead of `assert`. This is required to verify correct behavior even if NDEBUG
// is defined and to avoid `unused local variable` warnings with defined NDEBUG.
#include <boost/core/lightweight_test.hpp>
#ifdef assert
# undef assert
#endif
#define assert(X) if (!(X)) std::exit(__LINE__)
#define assert(X) BOOST_TEST(X)
/* !Comment block is not closed intentionaly!
//->
#include <cassert>

View File

@ -18,17 +18,14 @@
#include <boost/type_index.hpp>
//] [/type_index_my_type_index_worldwide_macro]
using namespace my_namespace;
//<-
// Using hand-made check
// instead of `assert`. This is required to verify correct behavior even if NDEBUG
// is defined and to avoid `unused local variable` warnings with defined NDEBUG.
#include <boost/core/lightweight_test.hpp>
#ifdef assert
# undef assert
#endif
#define assert(X) if (!(X)) std::exit(__LINE__)
#define assert(X) BOOST_TEST(X)
using namespace my_namespace;
int main() {
//[type_index_my_type_index_usage

View File

@ -1,5 +1,5 @@
//
// Copyright (c) Antony Polukhin, 2012-2014.
// Copyright (c) Antony Polukhin, 2012-2015.
//
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying

View File

@ -1,5 +1,5 @@
//
// Copyright (c) Antony Polukhin, 2012-2013.
// Copyright (c) Antony Polukhin, 2012-2015.
//
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying

View File

@ -1,5 +1,5 @@
//
// Copyright (c) Antony Polukhin, 2012-2014.
// Copyright (c) Antony Polukhin, 2012-2015.
//
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying

View File

@ -1,5 +1,5 @@
//
// Copyright (c) Antony Polukhin, 2012-2014.
// Copyright (c) Antony Polukhin, 2012-2015.
//
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying

View File

@ -1,17 +1,14 @@
//
// Copyright Antony Polukhin, 2012-2013.
// Copyright Antony Polukhin, 2012-2015.
//
// 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/test/minimal.hpp>
#include <boost/type_index.hpp>
#include "test_lib.hpp"
#define BOOST_CHECK_EQUAL(x, y) BOOST_CHECK(x == y)
#define BOOST_CHECK_NE(x, y) BOOST_CHECK(x != y)
#include <boost/core/lightweight_test.hpp>
namespace user_defined_namespace {
class user_defined{};
@ -22,10 +19,10 @@ void comparing_types_between_modules()
boost::typeindex::type_index t_const_int = boost::typeindex::type_id_with_cvr<const int>();
boost::typeindex::type_index t_int = boost::typeindex::type_id<int>();
BOOST_CHECK_EQUAL(t_int, test_lib::get_integer());
BOOST_CHECK_EQUAL(t_const_int, test_lib::get_const_integer());
BOOST_CHECK_NE(t_const_int, test_lib::get_integer());
BOOST_CHECK_NE(t_int, test_lib::get_const_integer());
BOOST_TEST_EQ(t_int, test_lib::get_integer());
BOOST_TEST_EQ(t_const_int, test_lib::get_const_integer());
BOOST_TEST_NE(t_const_int, test_lib::get_integer());
BOOST_TEST_NE(t_int, test_lib::get_const_integer());
boost::typeindex::type_index t_const_userdef
@ -33,16 +30,16 @@ void comparing_types_between_modules()
boost::typeindex::type_index t_userdef
= boost::typeindex::type_id<user_defined_namespace::user_defined>();
BOOST_CHECK_EQUAL(t_userdef, test_lib::get_user_defined_class());
BOOST_CHECK_EQUAL(t_const_userdef, test_lib::get_const_user_defined_class());
BOOST_CHECK_NE(t_const_userdef, test_lib::get_user_defined_class());
BOOST_CHECK_NE(t_userdef, test_lib::get_const_user_defined_class());
BOOST_TEST_EQ(t_userdef, test_lib::get_user_defined_class());
BOOST_TEST_EQ(t_const_userdef, test_lib::get_const_user_defined_class());
BOOST_TEST_NE(t_const_userdef, test_lib::get_user_defined_class());
BOOST_TEST_NE(t_userdef, test_lib::get_const_user_defined_class());
BOOST_CHECK_NE(t_userdef, test_lib::get_integer());
BOOST_CHECK_NE(t_const_userdef, test_lib::get_integer());
BOOST_CHECK_NE(t_int, test_lib::get_user_defined_class());
BOOST_CHECK_NE(t_const_int, test_lib::get_const_user_defined_class());
BOOST_TEST_NE(t_userdef, test_lib::get_integer());
BOOST_TEST_NE(t_const_userdef, test_lib::get_integer());
BOOST_TEST_NE(t_int, test_lib::get_user_defined_class());
BOOST_TEST_NE(t_const_int, test_lib::get_const_user_defined_class());
#ifndef BOOST_HAS_PRAGMA_DETECT_MISMATCH
test_lib::accept_typeindex(t_int);
@ -50,9 +47,9 @@ void comparing_types_between_modules()
}
int test_main(int , char* []) {
int main() {
comparing_types_between_modules();
return 0;
return boost::report_errors();
}

View File

@ -1,11 +1,11 @@
//
// Copyright Antony Polukhin, 2012-2014.
// Copyright Antony Polukhin, 2012-2015.
//
// 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/test/minimal.hpp"
#include <boost/core/lightweight_test.hpp>
#include <boost/type_index.hpp>
#include "test_lib_anonymous.hpp"
@ -21,15 +21,15 @@ void comparing_anonymous_types_between_modules()
boost::typeindex::type_index t_const_userdef = boost::typeindex::type_id_with_cvr<const user_defined>();
boost::typeindex::type_index t_userdef = boost::typeindex::type_id<user_defined>();
BOOST_CHECK_NE(t_userdef, test_lib::get_anonymous_user_defined_class());
BOOST_CHECK_NE(t_const_userdef, test_lib::get_const_anonymous_user_defined_class());
BOOST_CHECK_NE(t_const_userdef, test_lib::get_anonymous_user_defined_class());
BOOST_CHECK_NE(t_userdef, test_lib::get_const_anonymous_user_defined_class());
BOOST_TEST_NE(t_userdef, test_lib::get_anonymous_user_defined_class());
BOOST_TEST_NE(t_const_userdef, test_lib::get_const_anonymous_user_defined_class());
BOOST_TEST_NE(t_const_userdef, test_lib::get_anonymous_user_defined_class());
BOOST_TEST_NE(t_userdef, test_lib::get_const_anonymous_user_defined_class());
}
int test_main(int , char* []) {
int main() {
comparing_anonymous_types_between_modules();
return 0;
return boost::report_errors();
}

View File

@ -1,21 +1,18 @@
//
// Copyright Antony Polukhin, 2012-2014.
// Copyright Antony Polukhin, 2012-2015.
//
// 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/test/minimal.hpp>
#include <boost/type_index.hpp>
#include <boost/functional/hash.hpp>
#include <boost/lexical_cast.hpp>
#define BOOST_CHECK_EQUAL(x, y) BOOST_CHECK(x == y)
#define BOOST_CHECK_NE(x, y) BOOST_CHECK(x != y)
#define BOOST_CHECK_LE(x, y) BOOST_CHECK(x <= y)
#define BOOST_CHECK_GE(x, y) BOOST_CHECK(x >= y)
#include <boost/core/lightweight_test.hpp>
#define BOOST_TEST_LE(x, y) BOOST_TEST(x <= y)
#define BOOST_TEST_GE(x, y) BOOST_TEST(x >= y)
namespace my_namespace1 {
@ -31,24 +28,24 @@ namespace my_namespace2 {
void names_matches_type_id()
{
using namespace boost::typeindex;
BOOST_CHECK_EQUAL(type_id<int>().pretty_name(), "int");
BOOST_CHECK_EQUAL(type_id<double>().pretty_name(), "double");
BOOST_TEST_EQ(type_id<int>().pretty_name(), "int");
BOOST_TEST_EQ(type_id<double>().pretty_name(), "double");
BOOST_CHECK_EQUAL(type_id<int>().name(), type_id<int>().name());
BOOST_CHECK_NE(type_id<int>().name(), type_id<double>().name());
BOOST_CHECK_NE(type_id<double>().name(), type_id<int>().name());
BOOST_CHECK_EQUAL(type_id<double>().name(), type_id<double>().name());
BOOST_TEST_EQ(type_id<int>().name(), type_id<int>().name());
BOOST_TEST_NE(type_id<int>().name(), type_id<double>().name());
BOOST_TEST_NE(type_id<double>().name(), type_id<int>().name());
BOOST_TEST_EQ(type_id<double>().name(), type_id<double>().name());
}
void default_construction()
{
using namespace boost::typeindex;
type_index ti1, ti2;
BOOST_CHECK_EQUAL(ti1, ti2);
BOOST_CHECK_EQUAL(type_id<void>(), ti1);
BOOST_TEST_EQ(ti1, ti2);
BOOST_TEST_EQ(type_id<void>(), ti1);
BOOST_CHECK_EQUAL(type_id<void>().name(), ti1.name());
BOOST_CHECK_NE(type_id<int>(), ti1);
BOOST_TEST_EQ(type_id<void>().name(), ti1.name());
BOOST_TEST_NE(type_id<int>(), ti1);
}
@ -56,12 +53,12 @@ void copy_construction()
{
using namespace boost::typeindex;
type_index ti1, ti2 = type_id<int>();
BOOST_CHECK_NE(ti1, ti2);
BOOST_TEST_NE(ti1, ti2);
ti1 = ti2;
BOOST_CHECK_EQUAL(ti2, ti1);
BOOST_TEST_EQ(ti2, ti1);
const type_index ti3(ti1);
BOOST_CHECK_EQUAL(ti3, ti1);
BOOST_TEST_EQ(ti3, ti1);
}
void comparators_type_id()
@ -70,17 +67,17 @@ void comparators_type_id()
type_index t_int = type_id<int>();
type_index t_double = type_id<double>();
BOOST_CHECK_EQUAL(t_int, t_int);
BOOST_CHECK_LE(t_int, t_int);
BOOST_CHECK_GE(t_int, t_int);
BOOST_CHECK_NE(t_int, t_double);
BOOST_TEST_EQ(t_int, t_int);
BOOST_TEST_LE(t_int, t_int);
BOOST_TEST_GE(t_int, t_int);
BOOST_TEST_NE(t_int, t_double);
BOOST_CHECK_LE(t_double, t_double);
BOOST_CHECK_GE(t_double, t_double);
BOOST_CHECK_NE(t_double, t_int);
BOOST_TEST_LE(t_double, t_double);
BOOST_TEST_GE(t_double, t_double);
BOOST_TEST_NE(t_double, t_int);
BOOST_CHECK(t_double < t_int || t_int < t_double);
BOOST_CHECK(t_double > t_int || t_int > t_double);
BOOST_TEST(t_double < t_int || t_int < t_double);
BOOST_TEST(t_double > t_int || t_int > t_double);
}
void hash_code_type_id()
@ -92,9 +89,9 @@ void hash_code_type_id()
std::size_t t_int2 = type_id<int>().hash_code();
std::size_t t_double2 = type_id<double>().hash_code();
BOOST_CHECK_EQUAL(t_int1, t_int2);
BOOST_CHECK_NE(t_int1, t_double2);
BOOST_CHECK_LE(t_double1, t_double2);
BOOST_TEST_EQ(t_int1, t_int2);
BOOST_TEST_NE(t_int1, t_double2);
BOOST_TEST_LE(t_double1, t_double2);
}
@ -106,37 +103,37 @@ static void test_with_modofiers() {
type_index t1 = type_id_with_cvr<T1>();
type_index t2 = type_id_with_cvr<T2>();
BOOST_CHECK_NE(t2, t1);
BOOST_CHECK(t2 != t1.type_info());
BOOST_CHECK(t2.type_info() != t1);
BOOST_TEST_NE(t2, t1);
BOOST_TEST(t2 != t1.type_info());
BOOST_TEST(t2.type_info() != t1);
BOOST_CHECK(t1 < t2 || t2 < t1);
BOOST_CHECK(t1 > t2 || t2 > t1);
BOOST_CHECK(t1.type_info() < t2 || t2.type_info() < t1);
BOOST_CHECK(t1.type_info() > t2 || t2.type_info() > t1);
BOOST_CHECK(t1 < t2.type_info() || t2 < t1.type_info());
BOOST_CHECK(t1 > t2.type_info() || t2 > t1.type_info());
BOOST_TEST(t1 < t2 || t2 < t1);
BOOST_TEST(t1 > t2 || t2 > t1);
BOOST_TEST(t1.type_info() < t2 || t2.type_info() < t1);
BOOST_TEST(t1.type_info() > t2 || t2.type_info() > t1);
BOOST_TEST(t1 < t2.type_info() || t2 < t1.type_info());
BOOST_TEST(t1 > t2.type_info() || t2 > t1.type_info());
// Chaecking that comparison operators overloads compile
BOOST_CHECK(t1 <= t2 || t2 <= t1);
BOOST_CHECK(t1 >= t2 || t2 >= t1);
BOOST_CHECK(t1.type_info() <= t2 || t2.type_info() <= t1);
BOOST_CHECK(t1.type_info() >= t2 || t2.type_info() >= t1);
BOOST_CHECK(t1 <= t2.type_info() || t2 <= t1.type_info());
BOOST_CHECK(t1 >= t2.type_info() || t2 >= t1.type_info());
BOOST_TEST(t1 <= t2 || t2 <= t1);
BOOST_TEST(t1 >= t2 || t2 >= t1);
BOOST_TEST(t1.type_info() <= t2 || t2.type_info() <= t1);
BOOST_TEST(t1.type_info() >= t2 || t2.type_info() >= t1);
BOOST_TEST(t1 <= t2.type_info() || t2 <= t1.type_info());
BOOST_TEST(t1 >= t2.type_info() || t2 >= t1.type_info());
BOOST_CHECK_EQUAL(t1, type_id_with_cvr<T1>());
BOOST_CHECK_EQUAL(t2, type_id_with_cvr<T2>());
BOOST_CHECK(t1 == type_id_with_cvr<T1>().type_info());
BOOST_CHECK(t2 == type_id_with_cvr<T2>().type_info());
BOOST_CHECK(t1.type_info() == type_id_with_cvr<T1>());
BOOST_CHECK(t2.type_info() == type_id_with_cvr<T2>());
BOOST_TEST_EQ(t1, type_id_with_cvr<T1>());
BOOST_TEST_EQ(t2, type_id_with_cvr<T2>());
BOOST_TEST(t1 == type_id_with_cvr<T1>().type_info());
BOOST_TEST(t2 == type_id_with_cvr<T2>().type_info());
BOOST_TEST(t1.type_info() == type_id_with_cvr<T1>());
BOOST_TEST(t2.type_info() == type_id_with_cvr<T2>());
BOOST_CHECK_EQUAL(t1.hash_code(), type_id_with_cvr<T1>().hash_code());
BOOST_CHECK_EQUAL(t2.hash_code(), type_id_with_cvr<T2>().hash_code());
BOOST_TEST_EQ(t1.hash_code(), type_id_with_cvr<T1>().hash_code());
BOOST_TEST_EQ(t2.hash_code(), type_id_with_cvr<T2>().hash_code());
BOOST_CHECK_NE(t1.hash_code(), type_id_with_cvr<T2>().hash_code());
BOOST_CHECK_NE(t2.hash_code(), type_id_with_cvr<T1>().hash_code());
BOOST_TEST_NE(t1.hash_code(), type_id_with_cvr<T2>().hash_code());
BOOST_TEST_NE(t2.hash_code(), type_id_with_cvr<T1>().hash_code());
}
void type_id_storing_modifiers()
@ -194,14 +191,14 @@ static void test_storing_nonstoring_modifiers_templ() {
type_index t1 = type_id_with_cvr<T>();
type_index t2 = type_id<T>();
BOOST_CHECK_EQUAL(t2, t1);
BOOST_CHECK_EQUAL(t1, t2);
BOOST_CHECK(t1 <= t2);
BOOST_CHECK(t1 >= t2);
BOOST_CHECK(t2 <= t1);
BOOST_CHECK(t2 >= t1);
BOOST_TEST_EQ(t2, t1);
BOOST_TEST_EQ(t1, t2);
BOOST_TEST(t1 <= t2);
BOOST_TEST(t1 >= t2);
BOOST_TEST(t2 <= t1);
BOOST_TEST(t2 >= t1);
BOOST_CHECK_EQUAL(t2.pretty_name(), t1.pretty_name());
BOOST_TEST_EQ(t2.pretty_name(), t1.pretty_name());
}
void type_id_storing_modifiers_vs_nonstoring()
@ -212,8 +209,8 @@ void type_id_storing_modifiers_vs_nonstoring()
boost::typeindex::type_index t1 = boost::typeindex::type_id_with_cvr<const int>();
boost::typeindex::type_index t2 = boost::typeindex::type_id<int>();
BOOST_CHECK_NE(t2, t1);
BOOST_CHECK(t1.pretty_name() == "const int" || t1.pretty_name() == "int const");
BOOST_TEST_NE(t2, t1);
BOOST_TEST(t1.pretty_name() == "const int" || t1.pretty_name() == "int const");
}
void type_index_stream_operator_via_lexical_cast_testing()
@ -221,32 +218,32 @@ void type_index_stream_operator_via_lexical_cast_testing()
using namespace boost::typeindex;
std::string s_int2 = boost::lexical_cast<std::string>(type_id<int>());
BOOST_CHECK_EQUAL(s_int2, "int");
BOOST_TEST_EQ(s_int2, "int");
std::string s_double2 = boost::lexical_cast<std::string>(type_id<double>());
BOOST_CHECK_EQUAL(s_double2, "double");
BOOST_TEST_EQ(s_double2, "double");
}
void type_index_stripping_cvr_test()
{
using namespace boost::typeindex;
BOOST_CHECK_EQUAL(type_id<int>(), type_id<const int>());
BOOST_CHECK_EQUAL(type_id<int>(), type_id<const volatile int>());
BOOST_CHECK_EQUAL(type_id<int>(), type_id<const volatile int&>());
BOOST_TEST_EQ(type_id<int>(), type_id<const int>());
BOOST_TEST_EQ(type_id<int>(), type_id<const volatile int>());
BOOST_TEST_EQ(type_id<int>(), type_id<const volatile int&>());
BOOST_CHECK_EQUAL(type_id<int>(), type_id<int&>());
BOOST_CHECK_EQUAL(type_id<int>(), type_id<volatile int>());
BOOST_CHECK_EQUAL(type_id<int>(), type_id<volatile int&>());
BOOST_TEST_EQ(type_id<int>(), type_id<int&>());
BOOST_TEST_EQ(type_id<int>(), type_id<volatile int>());
BOOST_TEST_EQ(type_id<int>(), type_id<volatile int&>());
BOOST_CHECK_EQUAL(type_id<double>(), type_id<const double>());
BOOST_CHECK_EQUAL(type_id<double>(), type_id<const volatile double>());
BOOST_CHECK_EQUAL(type_id<double>(), type_id<const volatile double&>());
BOOST_TEST_EQ(type_id<double>(), type_id<const double>());
BOOST_TEST_EQ(type_id<double>(), type_id<const volatile double>());
BOOST_TEST_EQ(type_id<double>(), type_id<const volatile double&>());
BOOST_CHECK_EQUAL(type_id<double>(), type_id<double&>());
BOOST_CHECK_EQUAL(type_id<double>(), type_id<volatile double>());
BOOST_CHECK_EQUAL(type_id<double>(), type_id<volatile double&>());
BOOST_TEST_EQ(type_id<double>(), type_id<double&>());
BOOST_TEST_EQ(type_id<double>(), type_id<volatile double>());
BOOST_TEST_EQ(type_id<double>(), type_id<volatile double&>());
}
@ -254,18 +251,18 @@ void type_index_user_defined_class_test()
{
using namespace boost::typeindex;
BOOST_CHECK_EQUAL(type_id<my_namespace1::my_class>(), type_id<my_namespace1::my_class>());
BOOST_CHECK_EQUAL(type_id<my_namespace2::my_class>(), type_id<my_namespace2::my_class>());
BOOST_TEST_EQ(type_id<my_namespace1::my_class>(), type_id<my_namespace1::my_class>());
BOOST_TEST_EQ(type_id<my_namespace2::my_class>(), type_id<my_namespace2::my_class>());
#ifndef BOOST_NO_RTTI
BOOST_CHECK(type_id<my_namespace1::my_class>() == typeid(my_namespace1::my_class));
BOOST_CHECK(type_id<my_namespace2::my_class>() == typeid(my_namespace2::my_class));
BOOST_CHECK(typeid(my_namespace1::my_class) == type_id<my_namespace1::my_class>());
BOOST_CHECK(typeid(my_namespace2::my_class) == type_id<my_namespace2::my_class>());
BOOST_TEST(type_id<my_namespace1::my_class>() == typeid(my_namespace1::my_class));
BOOST_TEST(type_id<my_namespace2::my_class>() == typeid(my_namespace2::my_class));
BOOST_TEST(typeid(my_namespace1::my_class) == type_id<my_namespace1::my_class>());
BOOST_TEST(typeid(my_namespace2::my_class) == type_id<my_namespace2::my_class>());
#endif
BOOST_CHECK_NE(type_id<my_namespace1::my_class>(), type_id<my_namespace2::my_class>());
BOOST_CHECK_NE(
BOOST_TEST_NE(type_id<my_namespace1::my_class>(), type_id<my_namespace2::my_class>());
BOOST_TEST_NE(
type_id<my_namespace1::my_class>().pretty_name().find("my_namespace1::my_class"),
std::string::npos);
}
@ -298,37 +295,37 @@ void comparators_type_id_runtime()
A& rb1 = b1;
#ifndef BOOST_NO_RTTI
BOOST_CHECK(typeid(rc1) == typeid(*pc1));
BOOST_CHECK(typeid(rb1) == typeid(*pb1));
BOOST_TEST(typeid(rc1) == typeid(*pc1));
BOOST_TEST(typeid(rb1) == typeid(*pb1));
BOOST_CHECK(typeid(rc1) != typeid(*pb1));
BOOST_CHECK(typeid(rb1) != typeid(*pc1));
BOOST_TEST(typeid(rc1) != typeid(*pb1));
BOOST_TEST(typeid(rb1) != typeid(*pc1));
BOOST_CHECK(typeid(&rc1) == typeid(pb1));
BOOST_CHECK(typeid(&rb1) == typeid(pc1));
BOOST_TEST(typeid(&rc1) == typeid(pb1));
BOOST_TEST(typeid(&rb1) == typeid(pc1));
#else
BOOST_CHECK(boost::typeindex::type_index(pc1->boost_type_index_type_id_runtime_()).raw_name());
BOOST_TEST(boost::typeindex::type_index(pc1->boost_type_index_type_id_runtime_()).raw_name());
#endif
BOOST_CHECK_EQUAL(boost::typeindex::type_id_runtime(rc1), boost::typeindex::type_id_runtime(*pc1));
BOOST_CHECK_EQUAL(boost::typeindex::type_id<C>(), boost::typeindex::type_id_runtime(*pc1));
BOOST_CHECK_EQUAL(boost::typeindex::type_id_runtime(rb1), boost::typeindex::type_id_runtime(*pb1));
BOOST_CHECK_EQUAL(boost::typeindex::type_id<B>(), boost::typeindex::type_id_runtime(*pb1));
BOOST_TEST_EQ(boost::typeindex::type_id_runtime(rc1), boost::typeindex::type_id_runtime(*pc1));
BOOST_TEST_EQ(boost::typeindex::type_id<C>(), boost::typeindex::type_id_runtime(*pc1));
BOOST_TEST_EQ(boost::typeindex::type_id_runtime(rb1), boost::typeindex::type_id_runtime(*pb1));
BOOST_TEST_EQ(boost::typeindex::type_id<B>(), boost::typeindex::type_id_runtime(*pb1));
BOOST_CHECK_NE(boost::typeindex::type_id_runtime(rc1), boost::typeindex::type_id_runtime(*pb1));
BOOST_CHECK_NE(boost::typeindex::type_id_runtime(rb1), boost::typeindex::type_id_runtime(*pc1));
BOOST_TEST_NE(boost::typeindex::type_id_runtime(rc1), boost::typeindex::type_id_runtime(*pb1));
BOOST_TEST_NE(boost::typeindex::type_id_runtime(rb1), boost::typeindex::type_id_runtime(*pc1));
#ifndef BOOST_NO_RTTI
BOOST_CHECK_EQUAL(boost::typeindex::type_id_runtime(&rc1), boost::typeindex::type_id_runtime(pb1));
BOOST_CHECK_EQUAL(boost::typeindex::type_id_runtime(&rb1), boost::typeindex::type_id_runtime(pc1));
BOOST_TEST_EQ(boost::typeindex::type_id_runtime(&rc1), boost::typeindex::type_id_runtime(pb1));
BOOST_TEST_EQ(boost::typeindex::type_id_runtime(&rb1), boost::typeindex::type_id_runtime(pc1));
BOOST_CHECK(boost::typeindex::type_id_runtime(rc1) == typeid(*pc1));
BOOST_CHECK(boost::typeindex::type_id_runtime(rb1) == typeid(*pb1));
BOOST_TEST(boost::typeindex::type_id_runtime(rc1) == typeid(*pc1));
BOOST_TEST(boost::typeindex::type_id_runtime(rb1) == typeid(*pb1));
BOOST_CHECK(boost::typeindex::type_id_runtime(rc1) != typeid(*pb1));
BOOST_CHECK(boost::typeindex::type_id_runtime(rb1) != typeid(*pc1));
BOOST_CHECK(boost::typeindex::type_id_runtime(&rc1) == typeid(pb1));
BOOST_CHECK(boost::typeindex::type_id_runtime(&rb1) == typeid(pc1));
BOOST_TEST(boost::typeindex::type_id_runtime(rc1) != typeid(*pb1));
BOOST_TEST(boost::typeindex::type_id_runtime(rb1) != typeid(*pc1));
BOOST_TEST(boost::typeindex::type_id_runtime(&rc1) == typeid(pb1));
BOOST_TEST(boost::typeindex::type_id_runtime(&rb1) == typeid(pc1));
#endif
}
@ -340,44 +337,44 @@ void comparators_type_id_vs_type_info()
using namespace boost::typeindex;
type_index t_int = type_id<int>();
BOOST_CHECK(t_int == typeid(int));
BOOST_CHECK(typeid(int) == t_int);
BOOST_CHECK(t_int <= typeid(int));
BOOST_CHECK(typeid(int) <= t_int);
BOOST_CHECK(t_int >= typeid(int));
BOOST_CHECK(typeid(int) >= t_int);
BOOST_TEST(t_int == typeid(int));
BOOST_TEST(typeid(int) == t_int);
BOOST_TEST(t_int <= typeid(int));
BOOST_TEST(typeid(int) <= t_int);
BOOST_TEST(t_int >= typeid(int));
BOOST_TEST(typeid(int) >= t_int);
type_index t_double = type_id<double>();
BOOST_CHECK(t_double == typeid(double));
BOOST_CHECK(typeid(double) == t_double);
BOOST_CHECK(t_double <= typeid(double));
BOOST_CHECK(typeid(double) <= t_double);
BOOST_CHECK(t_double >= typeid(double));
BOOST_CHECK(typeid(double) >= t_double);
BOOST_TEST(t_double == typeid(double));
BOOST_TEST(typeid(double) == t_double);
BOOST_TEST(t_double <= typeid(double));
BOOST_TEST(typeid(double) <= t_double);
BOOST_TEST(t_double >= typeid(double));
BOOST_TEST(typeid(double) >= t_double);
if (t_double < t_int) {
BOOST_CHECK(t_double < typeid(int));
BOOST_CHECK(typeid(double) < t_int);
BOOST_CHECK(typeid(int) > t_double);
BOOST_CHECK(t_int > typeid(double));
BOOST_TEST(t_double < typeid(int));
BOOST_TEST(typeid(double) < t_int);
BOOST_TEST(typeid(int) > t_double);
BOOST_TEST(t_int > typeid(double));
BOOST_CHECK(t_double <= typeid(int));
BOOST_CHECK(typeid(double) <= t_int);
BOOST_CHECK(typeid(int) >= t_double);
BOOST_CHECK(t_int >= typeid(double));
BOOST_TEST(t_double <= typeid(int));
BOOST_TEST(typeid(double) <= t_int);
BOOST_TEST(typeid(int) >= t_double);
BOOST_TEST(t_int >= typeid(double));
} else {
BOOST_CHECK(t_double > typeid(int));
BOOST_CHECK(typeid(double) > t_int);
BOOST_CHECK(typeid(int) < t_double);
BOOST_CHECK(t_int < typeid(double));
BOOST_TEST(t_double > typeid(int));
BOOST_TEST(typeid(double) > t_int);
BOOST_TEST(typeid(int) < t_double);
BOOST_TEST(t_int < typeid(double));
BOOST_CHECK(t_double >= typeid(int));
BOOST_CHECK(typeid(double) >= t_int);
BOOST_CHECK(typeid(int) <= t_double);
BOOST_CHECK(t_int <= typeid(double));
BOOST_TEST(t_double >= typeid(int));
BOOST_TEST(typeid(double) >= t_int);
BOOST_TEST(typeid(int) <= t_double);
BOOST_TEST(t_int <= typeid(double));
}
}
@ -385,7 +382,7 @@ void comparators_type_id_vs_type_info()
#endif // BOOST_NO_RTTI
int test_main(int , char* []) {
int main() {
names_matches_type_id();
default_construction();
copy_construction();
@ -402,6 +399,6 @@ int test_main(int , char* []) {
#ifndef BOOST_NO_RTTI
comparators_type_id_vs_type_info();
#endif
return 0;
return boost::report_errors();
}

View File

@ -1,5 +1,5 @@
//
// Copyright Antony Polukhin, 2012-2013.
// Copyright Antony Polukhin, 2012-2015.
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at

View File

@ -1,5 +1,5 @@
//
// Copyright Antony Polukhin, 2012-2013.
// Copyright Antony Polukhin, 2012-2015.
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at

View File

@ -1,5 +1,5 @@
//
// Copyright Antony Polukhin, 2012-2013.
// Copyright Antony Polukhin, 2012-2015.
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at