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:
Daniel James
2006-02-13 18:26:00 +00:00
parent 5fdfe5d328
commit bf0ea56eac
19 changed files with 134 additions and 12 deletions

View File

@@ -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 ]
;
}

View File

@@ -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 ;

View File

@@ -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

View File

@@ -10,7 +10,7 @@
# ifdef TEST_STD_INCLUDES
# include <functional>
# else
# include <boost/functional/hash/hash.hpp>
# include <boost/functional/hash.hpp>
# endif
#endif

View File

@@ -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

View File

@@ -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>

View File

@@ -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

View File

@@ -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>

View File

@@ -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()

View 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;
}

View 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();
}

View 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();
}

View File

@@ -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>

View File

@@ -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>

View File

@@ -9,7 +9,7 @@
# ifdef TEST_STD_INCLUDES
# include <functional>
# else
# include <boost/functional/hash/hash.hpp>
# include <boost/functional/hash.hpp>
# endif
#endif

View File

@@ -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>

View File

@@ -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
View 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
View 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);
}