]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/unordered/test/exception/erase_exception_tests.cpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / libs / unordered / test / exception / erase_exception_tests.cpp
CommitLineData
7c673cae
FG
1
2// Copyright 2006-2009 Daniel James.
3// Distributed under the Boost Software License, Version 1.0. (See accompanying
4// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5
6#include "./containers.hpp"
b32b8144 7
7c673cae 8#include "../helpers/helpers.hpp"
b32b8144
FG
9#include "../helpers/invariants.hpp"
10#include "../helpers/random_values.hpp"
7c673cae
FG
11
12test::seed_t initialize_seed(835193);
13
b32b8144 14template <class T> struct erase_test_base : public test::exception_base
7c673cae 15{
b32b8144
FG
16 test::random_values<T> values;
17 erase_test_base(unsigned int count = 5) : values(count, test::limited_range)
18 {
19 }
7c673cae 20
b32b8144 21 typedef T data_type;
7c673cae 22
b32b8144 23 data_type init() const { return T(values.begin(), values.end()); }
7c673cae 24
b32b8144
FG
25 void check BOOST_PREVENT_MACRO_SUBSTITUTION(T const& x) const
26 {
27 std::string scope(test::scope);
7c673cae 28
b32b8144
FG
29 BOOST_TEST(scope.find("hash::") != std::string::npos ||
30 scope.find("equal_to::") != std::string::npos ||
31 scope == "operator==(object, object)");
7c673cae 32
b32b8144
FG
33 test::check_equivalent_keys(x);
34 }
7c673cae
FG
35};
36
b32b8144 37template <class T> struct erase_by_key_test1 : public erase_test_base<T>
7c673cae 38{
b32b8144
FG
39 void run(T& x) const
40 {
41 typedef BOOST_DEDUCED_TYPENAME test::random_values<T>::const_iterator
42 iterator;
43
44 for (iterator it = this->values.begin(), end = this->values.end();
45 it != end; ++it) {
46 x.erase(test::get_key<T>(*it));
7c673cae 47 }
b32b8144
FG
48
49 DISABLE_EXCEPTIONS;
50 BOOST_TEST(x.empty());
51 test::check_equivalent_keys(x);
52 }
7c673cae
FG
53};
54
b32b8144 55EXCEPTION_TESTS((erase_by_key_test1), CONTAINER_SEQ)
7c673cae 56RUN_TESTS()