diff --git a/hash/test/Jamfile b/hash/test/Jamfile index d1a2550..51cbe5d 100644 --- a/hash/test/Jamfile +++ b/hash/test/Jamfile @@ -41,7 +41,11 @@ rule hash-test ( names + : extras * ) [ hash-test hash_set_test ] [ hash-test hash_map_test ] [ hash-test link_test link_test_2 ] + [ hash-test link_ext_test link_no_ext_test ] [ run container_fwd_test.cpp : : : $(BOOST_ROOT) ] + [ compile-fail hash_no_ext_fail_test.cpp ] + [ run hash_no_ext_macro_1.cpp ] + [ run hash_no_ext_macro_2.cpp ] ; } diff --git a/hash/test/Jamfile.v2 b/hash/test/Jamfile.v2 index dbc878b..f6ead3f 100644 --- a/hash/test/Jamfile.v2 +++ b/hash/test/Jamfile.v2 @@ -32,7 +32,11 @@ test-suite functional/hash [ run hash_set_test.cpp ] [ run hash_map_test.cpp ] [ run link_test.cpp link_test_2.cpp ] + [ run link_ext_test.cpp link_no_ext_test.cpp ] [ run container_fwd_test.cpp ] + [ compile-fail hash_no_ext_fail_test.cpp ] + [ run hash_no_ext_macro_1.cpp ] + [ run hash_no_ext_macro_2.cpp ] ; build-project ../examples ; diff --git a/hash/test/config.hpp b/hash/test/config.hpp index 433c327..bb96b0e 100644 --- a/hash/test/config.hpp +++ b/hash/test/config.hpp @@ -9,5 +9,7 @@ # define HASH_NAMESPACE std::tr1 #else # define HASH_NAMESPACE boost -# define TEST_EXTENSIONS +# if !defined(BOOST_HASH_NO_EXTENSIONS) +# define TEST_EXTENSIONS +# endif #endif diff --git a/hash/test/hash_built_in_array_test.cpp b/hash/test/hash_built_in_array_test.cpp index 6d2f943..4d7a5de 100644 --- a/hash/test/hash_built_in_array_test.cpp +++ b/hash/test/hash_built_in_array_test.cpp @@ -10,7 +10,7 @@ # ifdef TEST_STD_INCLUDES # include # else -# include +# include # endif #endif diff --git a/hash/test/hash_custom_test.cpp b/hash/test/hash_custom_test.cpp index 613f128..d7f6fd3 100644 --- a/hash/test/hash_custom_test.cpp +++ b/hash/test/hash_custom_test.cpp @@ -45,7 +45,7 @@ namespace boost # ifdef TEST_STD_INCLUDES # include # else -# include +# include # endif #endif diff --git a/hash/test/hash_float_test.cpp b/hash/test/hash_float_test.cpp index 9bca421..9ef2a4b 100644 --- a/hash/test/hash_float_test.cpp +++ b/hash/test/hash_float_test.cpp @@ -8,7 +8,7 @@ #ifdef TEST_STD_INCLUDES # include #else -# include +# include #endif #include diff --git a/hash/test/hash_friend_test.cpp b/hash/test/hash_friend_test.cpp index e6fe156..3690f69 100644 --- a/hash/test/hash_friend_test.cpp +++ b/hash/test/hash_friend_test.cpp @@ -47,7 +47,7 @@ namespace boost # ifdef TEST_STD_INCLUDES # include # else -# include +# include # endif #endif diff --git a/hash/test/hash_function_pointer_test.cpp b/hash/test/hash_function_pointer_test.cpp index 5790a38..c7fd5d9 100644 --- a/hash/test/hash_function_pointer_test.cpp +++ b/hash/test/hash_function_pointer_test.cpp @@ -9,7 +9,7 @@ #ifdef TEST_STD_INCLUDES # include #else -# include +# include #endif #include diff --git a/hash/test/hash_fwd_test_1.cpp b/hash/test/hash_fwd_test_1.cpp index b296486..6de458e 100644 --- a/hash/test/hash_fwd_test_1.cpp +++ b/hash/test/hash_fwd_test_1.cpp @@ -11,7 +11,7 @@ #if defined(TEST_EXTENSIONS) && !defined(TEST_STD_INCLUDES) -#include +#include #include void fwd_test1() diff --git a/hash/test/hash_no_ext_fail_test.cpp b/hash/test/hash_no_ext_fail_test.cpp new file mode 100644 index 0000000..403dfd9 --- /dev/null +++ b/hash/test/hash_no_ext_fail_test.cpp @@ -0,0 +1,21 @@ + +// (C) Copyright Daniel James 2005. +// Use, modification and distribution are subject to 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 HASH_NAMESPACE boost + +// Simple test to make sure BOOST_HASH_NO_EXTENSIONS does disable extensions +// (or at least one of them). +#define BOOST_HASH_NO_EXTENSIONS + +#include +#include +#include + +int main() +{ + HASH_NAMESPACE::hash< std::set > hasher; + return 0; +} diff --git a/hash/test/hash_no_ext_macro_1.cpp b/hash/test/hash_no_ext_macro_1.cpp new file mode 100644 index 0000000..36e90eb --- /dev/null +++ b/hash/test/hash_no_ext_macro_1.cpp @@ -0,0 +1,26 @@ + +// (C) Copyright Daniel James 2005. +// Use, modification and distribution are subject to 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 HASH_NAMESPACE boost +#include +#define BOOST_HASH_NO_EXTENSIONS +#include +#include +#include +#include + +int main() +{ + std::deque x; + + x.push_back(1); + x.push_back(2); + + HASH_NAMESPACE::hash > hasher; + BOOST_TEST(hasher(x) == HASH_NAMESPACE::hash_value(x)); + + return boost::report_errors(); +} diff --git a/hash/test/hash_no_ext_macro_2.cpp b/hash/test/hash_no_ext_macro_2.cpp new file mode 100644 index 0000000..c90d424 --- /dev/null +++ b/hash/test/hash_no_ext_macro_2.cpp @@ -0,0 +1,26 @@ + +// (C) Copyright Daniel James 2005. +// Use, modification and distribution are subject to 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 HASH_NAMESPACE boost +#define BOOST_HASH_NO_EXTENSIONS +#include +#undef BOOST_HASH_NO_EXTENSIONS +#include +#include +#include + +int main() +{ + std::map x; + + x.insert(std::map::value_type(53, -42)); + x.insert(std::map::value_type(14, -75)); + + HASH_NAMESPACE::hash > hasher; + BOOST_TEST(hasher(x) == HASH_NAMESPACE::hash_value(x)); + + return boost::report_errors(); +} diff --git a/hash/test/hash_number_test.cpp b/hash/test/hash_number_test.cpp index 4859a9e..d386104 100644 --- a/hash/test/hash_number_test.cpp +++ b/hash/test/hash_number_test.cpp @@ -8,7 +8,7 @@ #ifdef TEST_STD_INCLUDES # include #else -# include +# include #endif #include diff --git a/hash/test/hash_pointer_test.cpp b/hash/test/hash_pointer_test.cpp index 66053c6..1151ccb 100644 --- a/hash/test/hash_pointer_test.cpp +++ b/hash/test/hash_pointer_test.cpp @@ -9,7 +9,7 @@ #ifdef TEST_STD_INCLUDES # include #else -# include +# include #endif #include diff --git a/hash/test/hash_range_test.cpp b/hash/test/hash_range_test.cpp index 0969efc..6149814 100644 --- a/hash/test/hash_range_test.cpp +++ b/hash/test/hash_range_test.cpp @@ -9,7 +9,7 @@ # ifdef TEST_STD_INCLUDES # include # else -# include +# include # endif #endif diff --git a/hash/test/hash_string_test.cpp b/hash/test/hash_string_test.cpp index 0e8c60f..b032808 100644 --- a/hash/test/hash_string_test.cpp +++ b/hash/test/hash_string_test.cpp @@ -8,7 +8,7 @@ #ifdef TEST_STD_INCLUDES # include #else -# include +# include #endif #include diff --git a/hash/test/hash_value_array_test.cpp b/hash/test/hash_value_array_test.cpp index 5b646b8..6d341be 100644 --- a/hash/test/hash_value_array_test.cpp +++ b/hash/test/hash_value_array_test.cpp @@ -13,7 +13,7 @@ # ifdef TEST_STD_INCLUDES # include # else -# include +# include # endif #endif diff --git a/hash/test/link_ext_test.cpp b/hash/test/link_ext_test.cpp new file mode 100644 index 0000000..f0fd492 --- /dev/null +++ b/hash/test/link_ext_test.cpp @@ -0,0 +1,22 @@ + +// (C) Copyright Daniel James 2005. +// Use, modification and distribution are subject to 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 HASH_NAMESPACE boost +#include +#include + +int f(std::size_t hash1, int* x1) { + // Check that HASH_NAMESPACE::hash works in both files. + HASH_NAMESPACE::hash ptr_hasher; + assert(hash1 == ptr_hasher(x1)); + + // Check that std::vector is avaiable in this file. + std::vector x; + x.push_back(*x1); + HASH_NAMESPACE::hash > vector_hasher; + return vector_hasher(x) != HASH_NAMESPACE::hash_value(x); +} + diff --git a/hash/test/link_no_ext_test.cpp b/hash/test/link_no_ext_test.cpp new file mode 100644 index 0000000..d4bbba4 --- /dev/null +++ b/hash/test/link_no_ext_test.cpp @@ -0,0 +1,17 @@ + +// (C) Copyright Daniel James 2005. +// Use, modification and distribution are subject to 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 HASH_NAMESPACE boost +#define BOOST_HASH_NO_EXTENSIONS +#include + +extern int f(std::size_t, int*); + +int main() { + HASH_NAMESPACE::hash ptr_hasher; + int x = 55; + return f(ptr_hasher(&x), &x); +}