forked from boostorg/type_index
Added cross module tests
This commit is contained in:
@@ -7,20 +7,22 @@
|
||||
import testing ;
|
||||
import feature ;
|
||||
|
||||
project
|
||||
: requirements
|
||||
<library>/boost/test//boost_unit_test_framework
|
||||
<link>static
|
||||
;
|
||||
tlib = /boost/test//boost_unit_test_framework/<link>static ;
|
||||
|
||||
lib test_lib_rtti : test_lib.cpp : <link>shared ;
|
||||
lib test_lib_nortti : test_lib.cpp : <link>shared <rtti>off ;
|
||||
|
||||
test-suite type_index
|
||||
:
|
||||
[ run type_index_test.cpp ]
|
||||
[ run template_index_test.cpp ]
|
||||
[ run testing_both.cpp ]
|
||||
[ run testing_both_no_rtti.cpp : : : <rtti>off ]
|
||||
[ run testing_minimal.cpp ]
|
||||
[ run testing_minimal_no_rtti.cpp : : : <rtti>off ]
|
||||
[ run type_index_test.cpp $(tlib) ]
|
||||
[ run template_index_test.cpp $(tlib) ]
|
||||
[ run testing_both.cpp $(tlib) ]
|
||||
[ run testing_both_no_rtti.cpp $(tlib) : : : <rtti>off ]
|
||||
[ run testing_minimal.cpp $(tlib) ]
|
||||
[ run testing_minimal_no_rtti.cpp $(tlib) : : : <rtti>off ]
|
||||
[ run testing_crossmodule.cpp test_lib_rtti $(tlib) ]
|
||||
[ run testing_crossmodule.cpp test_lib_nortti $(tlib) : : : <rtti>off : testing_crossmodule_no_rtti ]
|
||||
|
||||
# Examples that must work even with RTTI disabled
|
||||
[ run ../examples/registry.cpp : : : <rtti>off : registry_no_rtti ]
|
||||
[ run ../examples/exact_types_match.cpp : : : <rtti>off : exact_types_match_no_rtti ]
|
||||
|
27
libs/type_index/test/test_lib.cpp
Normal file
27
libs/type_index/test/test_lib.cpp
Normal file
@@ -0,0 +1,27 @@
|
||||
#define TEST_LIB_SOURCE
|
||||
#include "test_lib.hpp"
|
||||
|
||||
namespace user_defined_namespace {
|
||||
class user_defined{};
|
||||
}
|
||||
|
||||
namespace test_lib {
|
||||
|
||||
boost::type_index get_integer() {
|
||||
return boost::type_id<int>();
|
||||
}
|
||||
|
||||
boost::type_index get_user_defined_class() {
|
||||
return boost::type_id<user_defined_namespace::user_defined>();
|
||||
}
|
||||
|
||||
boost::type_index get_const_integer() {
|
||||
return boost::type_id_with_cvr<const int>();
|
||||
}
|
||||
|
||||
boost::type_index get_const_user_defined_class() {
|
||||
return boost::type_id_with_cvr<const user_defined_namespace::user_defined>();
|
||||
}
|
||||
|
||||
}
|
||||
|
37
libs/type_index/test/test_lib.hpp
Normal file
37
libs/type_index/test/test_lib.hpp
Normal file
@@ -0,0 +1,37 @@
|
||||
//
|
||||
// Copyright (c) Antony Polukhin, 2012-2013.
|
||||
//
|
||||
//
|
||||
// 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)
|
||||
//
|
||||
|
||||
#ifndef BOOST_TYPE_INDEX_TESTS_TEST_LIB_HPP
|
||||
#define BOOST_TYPE_INDEX_TESTS_TEST_LIB_HPP
|
||||
|
||||
// MS compatible compilers support #pragma once
|
||||
#if defined(_MSC_VER)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/type_index.hpp>
|
||||
|
||||
// This is ALWAYS a dynamic library
|
||||
#if defined(TEST_LIB_SOURCE)
|
||||
# define TEST_LIB_DECL BOOST_SYMBOL_EXPORT
|
||||
# else
|
||||
# define TEST_LIB_DECL BOOST_SYMBOL_IMPORT
|
||||
# endif
|
||||
|
||||
namespace test_lib {
|
||||
|
||||
TEST_LIB_DECL boost::type_index get_integer();
|
||||
TEST_LIB_DECL boost::type_index get_user_defined_class();
|
||||
|
||||
TEST_LIB_DECL boost::type_index get_const_integer();
|
||||
TEST_LIB_DECL boost::type_index get_const_user_defined_class();
|
||||
|
||||
}
|
||||
|
||||
#endif // BOOST_TYPE_INDEX_TESTS_LIB1_HPP
|
||||
|
43
libs/type_index/test/testing_crossmodule.cpp
Normal file
43
libs/type_index/test/testing_crossmodule.cpp
Normal file
@@ -0,0 +1,43 @@
|
||||
//
|
||||
// Copyright Antony Polukhin, 2012-2013.
|
||||
//
|
||||
// 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)
|
||||
|
||||
#define BOOST_TEST_MODULE testing_crossmodule_module
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
#include <boost/type_index/type_index_minimal.hpp>
|
||||
#include "test_lib.hpp"
|
||||
|
||||
namespace user_defined_namespace {
|
||||
class user_defined{};
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(comparing_types_between_modules)
|
||||
{
|
||||
boost::type_index t_const_int = boost::type_id_with_cvr<const int>();
|
||||
boost::type_index t_int = boost::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::type_index t_const_userdef = boost::type_id_with_cvr<const user_defined_namespace::user_defined>();
|
||||
boost::type_index t_userdef = boost::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_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());
|
||||
}
|
||||
|
Reference in New Issue
Block a user