diff --git a/CMake/CMakeLists.txt b/CMake/CMakeLists.txt index f488de7b..ea2c9833 100644 --- a/CMake/CMakeLists.txt +++ b/CMake/CMakeLists.txt @@ -20,9 +20,11 @@ if( CMAKE_CXX_COMPILER_ID STREQUAL "GNU" ) # we use gcc to test for C++03 compatibility add_definitions( std=c++03 ) message(STATUS "compiler is g++ c++03") + set(COMPILER_SUPPORTS_CXX11 FALSE) elseif( CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" ) add_definitions( /wd4996 ) message(STATUS "compiler is MSVC") + set(COMPILER_SUPPORTS_CXX11 TRUE) elseif( CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang" ) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ftemplate-depth=300") #set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++98") @@ -30,6 +32,7 @@ elseif( CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang" ) set(CMAKE_CXX_FLAGS_DEBUG "-g -O0" ) set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-g -O3" ) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -stdlib=libc++ -dead_strip") + set(COMPILER_SUPPORTS_CXX11 TRUE) endif() # @@ -281,7 +284,6 @@ archive_test(test_priority_queue A) archive_test(test_queue A) archive_test(test_recursion A) archive_test(test_registered) -archive_test(test_set A) archive_test(test_shared_ptr) archive_test(test_shared_ptr_multi_base) archive_test(test_shared_ptr_132) @@ -295,6 +297,17 @@ archive_test(test_unique_ptr) archive_test(test_valarray) archive_test(test_variant A) archive_test(test_vector A) +archive_test(test_set A) +if(COMPILER_SUPPORTS_CXX11) + archive_test(test_set_unordered A) +elseif() + archive_test(test_set_hashed A) +endif() +if(COMPILER_SUPPORTS_CXX11) + archive_test(test_map_unordered A) +elseif() + archive_test(test_map_hashed A) +endif() polymorphic_archive_test(test_polymorphic test_polymorphic_A A) polymorphic_archive_test(test_polymorphic2 test_polymorphic2imp) diff --git a/include/boost/serialization/static_warning.hpp b/include/boost/serialization/static_warning.hpp index cbbcb826..2d49de1c 100644 --- a/include/boost/serialization/static_warning.hpp +++ b/include/boost/serialization/static_warning.hpp @@ -96,7 +96,7 @@ struct BOOST_SERIALIZATION_SS {}; #define BOOST_SERIALIZATION_BSW(B, L) \ typedef boost::serialization::BOOST_SERIALIZATION_SS< \ sizeof( boost::serialization::static_warning_test< B, L > ) \ - > BOOST_JOIN(STATIC_WARNING_LINE, L) BOOST_STATIC_ASSERT_UNUSED_ATTRIBUTE; + > BOOST_JOIN(STATIC_WARNING_LINE, L) BOOST_ATTRIBUTE_UNUSED; #define BOOST_STATIC_WARNING(B) BOOST_SERIALIZATION_BSW(B, __LINE__) #endif // BOOST_SERIALIZATION_STATIC_WARNING_HPP diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index d52daac3..c157acb9 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -11,6 +11,9 @@ project libs/serialization/test : requirements /boost/filesystem ; +# import rules for testing conditional on config file variables +import ../../config/checks/config : requires ; + # import rules from the boost serialization test # import ../util/test : test-bsl-run-no-lib ; import ../util/test : @@ -93,6 +96,8 @@ test-suite "serialization" : [ test-bsl-run_files test_recursion : A ] [ test-bsl-run_files test_registered ] [ test-bsl-run_files test_set : A ] + [ test-bsl-run_files test_set_hashed : A : : [ requires hash ] ] # BOOST_HAS_HASH + [ test-bsl-run_files test_set_unordered : A : : [ requires cxx11_hdr_unordered_set ] ] # BOOST_NO_CXX11_HDR_UNORDERED_SET [ test-bsl-run_files test_simple_class : A ] [ test-bsl-run_files test_simple_class_ptr : A ] [ test-bsl-run_files test_split ] diff --git a/test/test_map.cpp b/test/test_map.cpp index fa2ab226..66e6f885 100644 --- a/test/test_map.cpp +++ b/test/test_map.cpp @@ -139,176 +139,11 @@ test_multimap(){ std::remove(testfile); } -#ifdef BOOST_HAS_HASH -#include - -namespace BOOST_STD_EXTENSION_NAMESPACE { - template<> - struct hash{ - std::size_t operator()(const random_key& r) const { - return static_cast(r); - } - }; -} // namespace BOOST_STD_EXTENSION_NAMESPACE - -void -test_hash_map(){ - const char * testfile = boost::archive::tmpnam(NULL); - BOOST_REQUIRE(NULL != testfile); - - BOOST_CHECKPOINT("hash_map"); - // test hash_map of objects - BOOST_STD_EXTENSION_NAMESPACE::hash_map ahash_map; - ahash_map.insert(std::make_pair(random_key(), A())); - ahash_map.insert(std::make_pair(random_key(), A())); - { - test_ostream os(testfile, TEST_STREAM_FLAGS); - test_oarchive oa(os, TEST_ARCHIVE_FLAGS); - oa << boost::serialization::make_nvp("ahashmap",ahash_map); - } - BOOST_STD_EXTENSION_NAMESPACE::hash_map ahash_map1; - { - test_istream is(testfile, TEST_STREAM_FLAGS); - test_iarchive ia(is, TEST_ARCHIVE_FLAGS); - ia >> boost::serialization::make_nvp("ahashmap",ahash_map1); - } - - std::vector< std::pair > tvec, tvec1; - std::copy(ahash_map.begin(), ahash_map.end(), std::back_inserter(tvec)); - std::sort(tvec.begin(), tvec.end()); - std::copy(ahash_map1.begin(), ahash_map1.end(), std::back_inserter(tvec1)); - std::sort(tvec1.begin(), tvec1.end()); - BOOST_CHECK(tvec == tvec1); - - std::remove(testfile); -} - -void -test_hash_multimap(){ - const char * testfile = boost::archive::tmpnam(NULL); - BOOST_REQUIRE(NULL != testfile); - - BOOST_CHECKPOINT("hash_multimap"); - BOOST_STD_EXTENSION_NAMESPACE::hash_multimap ahash_multimap; - ahash_multimap.insert(std::make_pair(random_key(), A())); - ahash_multimap.insert(std::make_pair(random_key(), A())); - { - test_ostream os(testfile, TEST_STREAM_FLAGS); - test_oarchive oa(os, TEST_ARCHIVE_FLAGS); - oa << boost::serialization::make_nvp("ahash_multimap", ahash_multimap); - } - BOOST_STD_EXTENSION_NAMESPACE::hash_multimap ahash_multimap1; - { - test_istream is(testfile, TEST_STREAM_FLAGS); - test_iarchive ia(is, TEST_ARCHIVE_FLAGS); - ia >> boost::serialization::make_nvp("ahash_multimap", ahash_multimap1); - } - std::vector< std::pair > tvec, tvec1; - tvec.clear(); - tvec1.clear(); - std::copy(ahash_multimap.begin(), ahash_multimap.end(), std::back_inserter(tvec)); - std::sort(tvec.begin(), tvec.end()); - std::copy(ahash_multimap1.begin(), ahash_multimap1.end(), std::back_inserter(tvec1)); - std::sort(tvec1.begin(), tvec1.end()); - BOOST_CHECK(tvec == tvec1); - std::remove(testfile); -} -#endif - -#ifndef BOOST_NO_CXX11_HDR_UNORDERED_MAP - -#include -#include // requires changeset [69520]; Ticket #5254 - -namespace std { - template<> - struct hash{ - std::size_t operator()(const random_key& r) const { - return static_cast(r); - } - }; -} // namespace std - -void -test_unordered_map(){ - const char * testfile = boost::archive::tmpnam(NULL); - BOOST_REQUIRE(NULL != testfile); - - BOOST_CHECKPOINT("unordered_map"); - // test unordered_map of objects - std::unordered_map anunordered_map; - anunordered_map.insert(std::make_pair(random_key(), A())); - anunordered_map.insert(std::make_pair(random_key(), A())); - { - test_ostream os(testfile, TEST_STREAM_FLAGS); - test_oarchive oa(os, TEST_ARCHIVE_FLAGS); - oa << boost::serialization::make_nvp("anunorderedmap",anunordered_map); - } - std::unordered_map anunordered_map1; - { - test_istream is(testfile, TEST_STREAM_FLAGS); - test_iarchive ia(is, TEST_ARCHIVE_FLAGS); - ia >> boost::serialization::make_nvp("anunorderedmap",anunordered_map1); - } - - std::vector< std::pair > tvec, tvec1; - std::copy(anunordered_map.begin(), anunordered_map.end(), std::back_inserter(tvec)); - std::sort(tvec.begin(), tvec.end()); - std::copy(anunordered_map1.begin(), anunordered_map1.end(), std::back_inserter(tvec1)); - std::sort(tvec1.begin(), tvec1.end()); - BOOST_CHECK(tvec == tvec1); - - std::remove(testfile); -} - -void -test_unordered_multimap(){ - const char * testfile = boost::archive::tmpnam(NULL); - BOOST_REQUIRE(NULL != testfile); - - BOOST_CHECKPOINT("unordered_multimap"); - std::unordered_multimap anunordered_multimap; - anunordered_multimap.insert(std::make_pair(random_key(), A())); - anunordered_multimap.insert(std::make_pair(random_key(), A())); - { - test_ostream os(testfile, TEST_STREAM_FLAGS); - test_oarchive oa(os, TEST_ARCHIVE_FLAGS); - oa << boost::serialization::make_nvp("anunordered_multimap", anunordered_multimap); - } - std::unordered_multimap anunordered_multimap1; - { - test_istream is(testfile, TEST_STREAM_FLAGS); - test_iarchive ia(is, TEST_ARCHIVE_FLAGS); - ia >> boost::serialization::make_nvp("anunordered_multimap", anunordered_multimap1); - } - std::vector< std::pair > tvec, tvec1; - tvec.clear(); - tvec1.clear(); - std::copy(anunordered_multimap.begin(), anunordered_multimap.end(), std::back_inserter(tvec)); - std::sort(tvec.begin(), tvec.end()); - std::copy(anunordered_multimap1.begin(), anunordered_multimap1.end(), std::back_inserter(tvec1)); - std::sort(tvec1.begin(), tvec1.end()); - BOOST_CHECK(tvec == tvec1); - std::remove(testfile); -} - -#endif - int test_main( int /* argc */, char* /* argv */[] ) { test_map(); test_map_2(); test_multimap(); - #ifdef BOOST_HAS_HASH - test_hash_map(); - test_hash_multimap(); - #endif - - #ifndef BOOST_NO_CXX11_HDR_UNORDERED_MAP - test_unordered_map(); - test_unordered_multimap(); - #endif - return EXIT_SUCCESS; } diff --git a/test/test_set.cpp b/test/test_set.cpp index 8379c77f..6a86f049 100644 --- a/test/test_set.cpp +++ b/test/test_set.cpp @@ -87,176 +87,9 @@ test_multiset(){ std::remove(testfile); } -#ifdef BOOST_HAS_HASH - -#include - -namespace BOOST_STD_EXTENSION_NAMESPACE { - template<> - struct hash { - std::size_t operator()(const A& a) const { - return static_cast(a); - } - }; -} - -void -test_hash_set(){ - const char * testfile = boost::archive::tmpnam(NULL); - BOOST_REQUIRE(NULL != testfile); - - // test array of objects - BOOST_STD_EXTENSION_NAMESPACE::hash_set ahash_set; - A a, a1; - ahash_set.insert(a); - ahash_set.insert(a1); - { - test_ostream os(testfile, TEST_STREAM_FLAGS); - test_oarchive oa(os, TEST_ARCHIVE_FLAGS); - oa << boost::serialization::make_nvp("ahash_set", ahash_set); - } - BOOST_STD_EXTENSION_NAMESPACE::hash_set ahash_set1; - { - test_istream is(testfile, TEST_STREAM_FLAGS); - test_iarchive ia(is, TEST_ARCHIVE_FLAGS); - ia >> boost::serialization::make_nvp("ahash_set", ahash_set1); - } - std::vector tvec, tvec1; - tvec.clear(); - tvec1.clear(); - std::copy(ahash_set.begin(), ahash_set.end(), std::back_inserter(tvec)); - std::sort(tvec.begin(), tvec.end()); - std::copy(ahash_set1.begin(), ahash_set1.end(), std::back_inserter(tvec1)); - std::sort(tvec1.begin(), tvec1.end()); - BOOST_CHECK(tvec == tvec1); - std::remove(testfile); -} - -void -test_hash_multiset(){ - const char * testfile = boost::archive::tmpnam(NULL); - BOOST_REQUIRE(NULL != testfile); - - BOOST_STD_EXTENSION_NAMESPACE::hash_multiset ahash_multiset; - ahash_multiset.insert(A()); - ahash_multiset.insert(A()); - { - test_ostream os(testfile, TEST_STREAM_FLAGS); - test_oarchive oa(os, TEST_ARCHIVE_FLAGS); - oa << boost::serialization::make_nvp("ahash_multiset", ahash_multiset); - } - BOOST_STD_EXTENSION_NAMESPACE::hash_multiset ahash_multiset1; - { - test_istream is(testfile, TEST_STREAM_FLAGS); - test_iarchive ia(is, TEST_ARCHIVE_FLAGS); - ia >> boost::serialization::make_nvp("ahash_multiset", ahash_multiset1); - } - - std::vector tvec, tvec1; - tvec.clear(); - tvec1.clear(); - std::copy(ahash_multiset.begin(), ahash_multiset.end(), std::back_inserter(tvec)); - std::sort(tvec.begin(), tvec.end()); - std::copy(ahash_multiset1.begin(), ahash_multiset1.end(), std::back_inserter(tvec1)); - std::sort(tvec1.begin(), tvec1.end()); - BOOST_CHECK(tvec == tvec1); - - std::remove(testfile); -} -#endif - -#ifndef BOOST_NO_CXX11_HDR_UNORDERED_SET - -#include -#include // requires changeset [69520]; Ticket #5254 - -namespace std { - template<> - struct hash { - std::size_t operator()(const A& a) const { - return static_cast(a); - } - }; -} // namespace std - -void -test_unordered_set(){ - const char * testfile = boost::archive::tmpnam(NULL); - BOOST_REQUIRE(NULL != testfile); - - // test array of objects - std::unordered_set anunordered_set; - A a, a1; - anunordered_set.insert(a); - anunordered_set.insert(a1); - { - test_ostream os(testfile, TEST_STREAM_FLAGS); - test_oarchive oa(os, TEST_ARCHIVE_FLAGS); - oa << boost::serialization::make_nvp("anunordered_set", anunordered_set); - } - std::unordered_set anunordered_set1; - { - test_istream is(testfile, TEST_STREAM_FLAGS); - test_iarchive ia(is, TEST_ARCHIVE_FLAGS); - ia >> boost::serialization::make_nvp("anunordered_set", anunordered_set1); - } - std::vector tvec, tvec1; - tvec.clear(); - tvec1.clear(); - std::copy(anunordered_set.begin(), anunordered_set.end(), std::back_inserter(tvec)); - std::sort(tvec.begin(), tvec.end()); - std::copy(anunordered_set1.begin(), anunordered_set1.end(), std::back_inserter(tvec1)); - std::sort(tvec1.begin(), tvec1.end()); - BOOST_CHECK(tvec == tvec1); - std::remove(testfile); -} - -void -test_unordered_multiset(){ - const char * testfile = boost::archive::tmpnam(NULL); - BOOST_REQUIRE(NULL != testfile); - - std::unordered_multiset anunordered_multiset; - anunordered_multiset.insert(A()); - anunordered_multiset.insert(A()); - { - test_ostream os(testfile, TEST_STREAM_FLAGS); - test_oarchive oa(os, TEST_ARCHIVE_FLAGS); - oa << boost::serialization::make_nvp("anunordered_multiset", anunordered_multiset); - } - std::unordered_multiset anunordered_multiset1; - { - test_istream is(testfile, TEST_STREAM_FLAGS); - test_iarchive ia(is, TEST_ARCHIVE_FLAGS); - ia >> boost::serialization::make_nvp("anunordered_multiset", anunordered_multiset1); - } - - std::vector tvec, tvec1; - tvec.clear(); - tvec1.clear(); - std::copy(anunordered_multiset.begin(), anunordered_multiset.end(), std::back_inserter(tvec)); - std::sort(tvec.begin(), tvec.end()); - std::copy(anunordered_multiset1.begin(), anunordered_multiset1.end(), std::back_inserter(tvec1)); - std::sort(tvec1.begin(), tvec1.end()); - BOOST_CHECK(tvec == tvec1); - - std::remove(testfile); -} -#endif - int test_main( int /* argc */, char* /* argv */[] ){ test_set(); test_multiset(); - #ifdef BOOST_HAS_HASH - test_hash_set(); - test_hash_multiset(); - #endif - - #ifndef BOOST_NO_CXX11_HDR_UNORDERED_SET - test_unordered_set(); - test_unordered_multiset(); - #endif - return EXIT_SUCCESS; } diff --git a/util/test.jam b/util/test.jam index 18178c37..b9e2ae33 100644 --- a/util/test.jam +++ b/util/test.jam @@ -176,16 +176,15 @@ rule test-bsl-run_files ( test-name : sources * : libs * : requirements * ) { return $(tests) ; } -rule test-bsl-run_polymorphic_archive ( test-name : sources * ) { +rule test-bsl-run_polymorphic_archive ( test-name : sources * : requirements * ) { local tests ; for local defn in $(BOOST_ARCHIVE_LIST) { tests += [ test-bsl-run_archive $(test-name) : polymorphic_$(defn:LB) - : $(test-name) $(sources) + : $(test-name) $(sources) $(requirements) ] ; } return $(tests) ; } -