forked from boostorg/container_hash
Add to the hash tests, tests for the BOOST_HASH_NO_EXTENSIONS macro and a few other updates.
[SVN r32901]
This commit is contained in:
@@ -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 : : : <include>$(BOOST_ROOT) ]
|
||||
[ compile-fail hash_no_ext_fail_test.cpp ]
|
||||
[ run hash_no_ext_macro_1.cpp ]
|
||||
[ run hash_no_ext_macro_2.cpp ]
|
||||
;
|
||||
}
|
||||
|
||||
|
@@ -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 ;
|
||||
|
@@ -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
|
||||
|
@@ -10,7 +10,7 @@
|
||||
# ifdef TEST_STD_INCLUDES
|
||||
# include <functional>
|
||||
# else
|
||||
# include <boost/functional/hash/hash.hpp>
|
||||
# include <boost/functional/hash.hpp>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
@@ -45,7 +45,7 @@ namespace boost
|
||||
# ifdef TEST_STD_INCLUDES
|
||||
# include <functional>
|
||||
# else
|
||||
# include <boost/functional/hash/hash.hpp>
|
||||
# include <boost/functional/hash.hpp>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
@@ -8,7 +8,7 @@
|
||||
#ifdef TEST_STD_INCLUDES
|
||||
# include <functional>
|
||||
#else
|
||||
# include <boost/functional/hash/hash.hpp>
|
||||
# include <boost/functional/hash.hpp>
|
||||
#endif
|
||||
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
|
@@ -47,7 +47,7 @@ namespace boost
|
||||
# ifdef TEST_STD_INCLUDES
|
||||
# include <functional>
|
||||
# else
|
||||
# include <boost/functional/hash/hash.hpp>
|
||||
# include <boost/functional/hash.hpp>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
@@ -9,7 +9,7 @@
|
||||
#ifdef TEST_STD_INCLUDES
|
||||
# include <functional>
|
||||
#else
|
||||
# include <boost/functional/hash/hash.hpp>
|
||||
# include <boost/functional/hash.hpp>
|
||||
#endif
|
||||
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
|
@@ -11,7 +11,7 @@
|
||||
|
||||
#if defined(TEST_EXTENSIONS) && !defined(TEST_STD_INCLUDES)
|
||||
|
||||
#include <boost/functional/hash/hash.hpp>
|
||||
#include <boost/functional/hash.hpp>
|
||||
#include <string>
|
||||
|
||||
void fwd_test1()
|
||||
|
21
test/hash_no_ext_fail_test.cpp
Normal file
21
test/hash_no_ext_fail_test.cpp
Normal file
@@ -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 <boost/functional/hash.hpp>
|
||||
#include <boost/functional/hash.hpp>
|
||||
#include <set>
|
||||
|
||||
int main()
|
||||
{
|
||||
HASH_NAMESPACE::hash< std::set<int> > hasher;
|
||||
return 0;
|
||||
}
|
26
test/hash_no_ext_macro_1.cpp
Normal file
26
test/hash_no_ext_macro_1.cpp
Normal file
@@ -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 <boost/functional/hash.hpp>
|
||||
#define BOOST_HASH_NO_EXTENSIONS
|
||||
#include <boost/functional/hash.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <deque>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
{
|
||||
std::deque<int> x;
|
||||
|
||||
x.push_back(1);
|
||||
x.push_back(2);
|
||||
|
||||
HASH_NAMESPACE::hash<std::deque<int> > hasher;
|
||||
BOOST_TEST(hasher(x) == HASH_NAMESPACE::hash_value(x));
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
26
test/hash_no_ext_macro_2.cpp
Normal file
26
test/hash_no_ext_macro_2.cpp
Normal file
@@ -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 <boost/functional/hash.hpp>
|
||||
#undef BOOST_HASH_NO_EXTENSIONS
|
||||
#include <boost/functional/hash.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <map>
|
||||
|
||||
int main()
|
||||
{
|
||||
std::map<int, int> x;
|
||||
|
||||
x.insert(std::map<int, int>::value_type(53, -42));
|
||||
x.insert(std::map<int, int>::value_type(14, -75));
|
||||
|
||||
HASH_NAMESPACE::hash<std::map<int, int> > hasher;
|
||||
BOOST_TEST(hasher(x) == HASH_NAMESPACE::hash_value(x));
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
@@ -8,7 +8,7 @@
|
||||
#ifdef TEST_STD_INCLUDES
|
||||
# include <functional>
|
||||
#else
|
||||
# include <boost/functional/hash/hash.hpp>
|
||||
# include <boost/functional/hash.hpp>
|
||||
#endif
|
||||
|
||||
#include <iostream>
|
||||
|
@@ -9,7 +9,7 @@
|
||||
#ifdef TEST_STD_INCLUDES
|
||||
# include <functional>
|
||||
#else
|
||||
# include <boost/functional/hash/hash.hpp>
|
||||
# include <boost/functional/hash.hpp>
|
||||
#endif
|
||||
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
|
@@ -9,7 +9,7 @@
|
||||
# ifdef TEST_STD_INCLUDES
|
||||
# include <functional>
|
||||
# else
|
||||
# include <boost/functional/hash/hash.hpp>
|
||||
# include <boost/functional/hash.hpp>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
@@ -8,7 +8,7 @@
|
||||
#ifdef TEST_STD_INCLUDES
|
||||
# include <functional>
|
||||
#else
|
||||
# include <boost/functional/hash/hash.hpp>
|
||||
# include <boost/functional/hash.hpp>
|
||||
#endif
|
||||
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
|
@@ -13,7 +13,7 @@
|
||||
# ifdef TEST_STD_INCLUDES
|
||||
# include <functional>
|
||||
# else
|
||||
# include <boost/functional/hash/hash.hpp>
|
||||
# include <boost/functional/hash.hpp>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
22
test/link_ext_test.cpp
Normal file
22
test/link_ext_test.cpp
Normal file
@@ -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 <boost/functional/hash.hpp>
|
||||
#include <vector>
|
||||
|
||||
int f(std::size_t hash1, int* x1) {
|
||||
// Check that HASH_NAMESPACE::hash<int*> works in both files.
|
||||
HASH_NAMESPACE::hash<int*> ptr_hasher;
|
||||
assert(hash1 == ptr_hasher(x1));
|
||||
|
||||
// Check that std::vector<std::size_t> is avaiable in this file.
|
||||
std::vector<std::size_t> x;
|
||||
x.push_back(*x1);
|
||||
HASH_NAMESPACE::hash<std::vector<std::size_t> > vector_hasher;
|
||||
return vector_hasher(x) != HASH_NAMESPACE::hash_value(x);
|
||||
}
|
||||
|
17
test/link_no_ext_test.cpp
Normal file
17
test/link_no_ext_test.cpp
Normal file
@@ -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 <boost/functional/hash.hpp>
|
||||
|
||||
extern int f(std::size_t, int*);
|
||||
|
||||
int main() {
|
||||
HASH_NAMESPACE::hash<int*> ptr_hasher;
|
||||
int x = 55;
|
||||
return f(ptr_hasher(&x), &x);
|
||||
}
|
Reference in New Issue
Block a user