forked from boostorg/unordered
Update the unordered tests. Several changes including extra erase tests. The newer version of the containers have a hairy erase implementation, so need to test all the special cases. Also, a few extra tests here and there, avoid a couple of warnings and remove some old TODOs.
[SVN r3341]
This commit is contained in:
1 parent
136e2fe3ba
commit
ec310f7b80
20 files changed
+316
-134
No files matched your search
+19
-42
@@ -10,25 +10,31 @@
|
||||
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#if 0
|
||||
#include <stdexcept>
|
||||
#include <boost/random/inversive_congruential.hpp>
|
||||
#include <boost/random/uniform_int.hpp>
|
||||
#include <boost/random/lagged_fibonacci.hpp>
|
||||
#include <boost/random/uniform_real.hpp>
|
||||
#include <boost/random/variate_generator.hpp>
|
||||
#else
|
||||
#include <cstdlib>
|
||||
#endif
|
||||
|
||||
#include "./fwd.hpp"
|
||||
|
||||
namespace test
|
||||
{
|
||||
#if 0
|
||||
typedef boost::hellekalek1995 integer_generator_type;
|
||||
typedef boost::lagged_fibonacci607 real_generator_type;
|
||||
#endif
|
||||
|
||||
template <class T>
|
||||
struct generator;
|
||||
|
||||
template <class T1, class T2> std::pair<T1, T2> generate(
|
||||
std::pair<T1, T2> const*)
|
||||
{
|
||||
static generator<T1> g1;
|
||||
static generator<T2> g2;
|
||||
|
||||
return std::pair<T1, T2>(g1(), g2());
|
||||
}
|
||||
|
||||
template <class T>
|
||||
struct generator
|
||||
@@ -42,30 +48,20 @@ namespace test
|
||||
|
||||
inline int generate(int const*)
|
||||
{
|
||||
#if 0
|
||||
integer_generator_type gen;
|
||||
boost::uniform_int<> dist(0, 1000);
|
||||
static integer_generator_type gen;
|
||||
static boost::uniform_int<> dist(0, 1000);
|
||||
static boost::variate_generator<integer_generator_type, boost::uniform_int<> >
|
||||
vg(gen, dist);
|
||||
return vg();
|
||||
#else
|
||||
using namespace std;
|
||||
return rand();
|
||||
#endif
|
||||
}
|
||||
|
||||
inline char generate(char const*)
|
||||
{
|
||||
#if 0
|
||||
integer_generator_type gen;
|
||||
boost::uniform_int<char> dist(32, 127);
|
||||
static integer_generator_type gen;
|
||||
static boost::uniform_int<char> dist(32, 127);
|
||||
static boost::variate_generator<integer_generator_type, boost::uniform_int<char> >
|
||||
vg(gen, dist);
|
||||
return vg();
|
||||
#else
|
||||
using namespace std;
|
||||
return rand() % (128 - 32) + 32;
|
||||
#endif
|
||||
}
|
||||
|
||||
inline std::string generate(std::string const*)
|
||||
@@ -80,35 +76,16 @@ namespace test
|
||||
for(int i = 0; i < length; ++i)
|
||||
result += char_gen();
|
||||
|
||||
//std::generate_n(
|
||||
// std::back_inserter(result),
|
||||
// rand() % 10,
|
||||
// char_gen);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
float generate(float const*)
|
||||
{
|
||||
#if 0
|
||||
real_generator_type gen;
|
||||
boost::uniform_real<float> dist;
|
||||
static real_generator_type gen;
|
||||
static boost::uniform_real<float> dist;
|
||||
static boost::variate_generator<real_generator_type, boost::uniform_real<float> >
|
||||
vg(gen, dist);
|
||||
return vg();
|
||||
#else
|
||||
using namespace std;
|
||||
return (double) rand() / (double) RAND_MAX;
|
||||
#endif
|
||||
}
|
||||
|
||||
template <class T1, class T2> std::pair<T1, T2> generate(
|
||||
std::pair<T1, T2> const*)
|
||||
{
|
||||
static generator<T1> g1;
|
||||
static generator<T2> g2;
|
||||
|
||||
return std::pair<T1, T2>(g1(), g2());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
|
||||
namespace test
|
||||
{
|
||||
// TODO: Make this a stricter input iterator.
|
||||
template <class Iterator>
|
||||
struct input_iterator_adaptor
|
||||
: boost::iterator_adaptor<
|
||||
|
||||
@@ -49,8 +49,10 @@ namespace test
|
||||
if(test::has_unique_keys<X>::value && count != 1)
|
||||
BOOST_ERROR("Non-unique key.");
|
||||
|
||||
if(x1.count(key) != count)
|
||||
if(x1.count(key) != count) {
|
||||
BOOST_ERROR("Incorrect output of count.");
|
||||
std::cerr<<x1.count(key)<<","<<count<<"\n";
|
||||
}
|
||||
|
||||
// I'm not bothering with the following test for now, as the
|
||||
// previous test is probably more enough to catch the kind of
|
||||
|
||||
@@ -6,21 +6,19 @@
|
||||
#if !defined(BOOST_UNORDERED_TEST_HELPERS_RANDOM_VALUES_HEADER)
|
||||
#define BOOST_UNORDERED_TEST_HELPERS_RANDOM_VALUES_HEADER
|
||||
|
||||
#include <vector>
|
||||
#include <list>
|
||||
#include <algorithm>
|
||||
#include "./generators.hpp"
|
||||
#include "./metafunctions.hpp"
|
||||
|
||||
namespace test
|
||||
{
|
||||
template <class X>
|
||||
struct random_values
|
||||
: public std::vector<typename non_const_value_type<X>::type>
|
||||
: public std::list<typename X::value_type>
|
||||
{
|
||||
random_values(int count) {
|
||||
typedef typename non_const_value_type<X>::type value_type;
|
||||
typedef typename X::value_type value_type;
|
||||
static test::generator<value_type> gen;
|
||||
this->reserve(count);
|
||||
std::generate_n(std::back_inserter(*this), count, gen);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -22,14 +22,6 @@ namespace test
|
||||
values_type values_;
|
||||
public:
|
||||
void store(X const& x) {
|
||||
// TODO: Well, I shouldn't be disabling exceptions here. Instead
|
||||
// the test runner should provide a method to the test which
|
||||
// disables exceptions and calls this.
|
||||
//
|
||||
// Actually, the test runner could also keep track of how many times
|
||||
// store is called in a run. Because it knows that in the next run
|
||||
// the first n-1 stores are unnecessary - since no exceptions will
|
||||
// be thrown for them.
|
||||
DISABLE_EXCEPTIONS;
|
||||
values_.clear();
|
||||
values_.reserve(x.size());
|
||||
|
||||
@@ -138,8 +138,7 @@ namespace test
|
||||
};
|
||||
|
||||
template <class Equals>
|
||||
typename equals_to_compare<Equals>::type create_compare(
|
||||
Equals const& equals)
|
||||
typename equals_to_compare<Equals>::type create_compare(Equals const&)
|
||||
{
|
||||
typename equals_to_compare<Equals>::type x;
|
||||
return x;
|
||||
|
||||
Reference in new issue
Block a user