1
2// Copyright 2005-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#if !defined(BOOST_UNORDERED_TEST_HELPERS_STRONG_HEADER)
7#define BOOST_UNORDERED_TEST_HELPERS_STRONG_HEADER
8
9#include "./equivalent.hpp"
10#include "./exception_test.hpp"
11#include "./list.hpp"
12#include <boost/config.hpp>
13#include <iterator>
14
15namespace test {
16 template <class X> class strong
17 {
18 typedef test::list<typename X::value_type> values_type;
19 values_type values_;
20 unsigned int allocations_;
21
22 public:
23 void store(X const& x, unsigned int allocations = 0)
24 {
25 DISABLE_EXCEPTIONS;
26 values_.clear();
27 values_.insert(x.cbegin(), x.cend());
28 allocations_ = allocations;
29 }
30
31 void test(X const& x, unsigned int allocations = 0) const
32 {
33 if (!(x.size() == values_.size() && test::equal(x.cbegin(), x.cend(),
34 values_.begin(), test::equivalent)))
35 BOOST_ERROR("Strong exception safety failure.");
36 if (allocations != allocations_)
37 BOOST_ERROR("Strong exception failure: extra allocations.");
38 }
39 };
40}
41
42#endif
43

source code of boost/libs/unordered/test/helpers/strong.hpp