| 1 | /*============================================================================= |
|---|---|
| 2 | Copyright (c) 2004 Angus Leeming |
| 3 | Copyright (c) 2017 Kohei Takahashi |
| 4 | |
| 5 | Distributed under the Boost Software License, Version 1.0. (See accompanying |
| 6 | file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) |
| 7 | ==============================================================================*/ |
| 8 | #include "container_tests.hpp" |
| 9 | #include <boost/static_assert.hpp> |
| 10 | |
| 11 | std::unordered_set<int> const build_unordered_set() |
| 12 | { |
| 13 | typedef std::unordered_set<int> int_set; |
| 14 | typedef std::vector<int> int_vector; |
| 15 | |
| 16 | int_set result; |
| 17 | int_vector const data = build_vector(); |
| 18 | int_vector::const_iterator it = data.begin(); |
| 19 | int_vector::const_iterator const end = data.end(); |
| 20 | result.insert(first: it, last: end); |
| 21 | return result; |
| 22 | } |
| 23 | |
| 24 | std::vector<int> const init_vector() |
| 25 | { |
| 26 | typedef std::vector<int> int_vector; |
| 27 | int const data[] = { -4, -3, -2, -1, 0 }; |
| 28 | int_vector::size_type const data_size = sizeof(data) / sizeof(data[0]); |
| 29 | return int_vector(data, data + data_size); |
| 30 | } |
| 31 | |
| 32 | std::vector<int> const build_vector() |
| 33 | { |
| 34 | typedef std::vector<int> int_vector; |
| 35 | static int_vector data = init_vector(); |
| 36 | int_vector::size_type const size = data.size(); |
| 37 | int_vector::iterator it = data.begin(); |
| 38 | int_vector::iterator const end = data.end(); |
| 39 | for (; it != end; ++it) |
| 40 | *it += size; |
| 41 | return data; |
| 42 | } |
| 43 | |
| 44 | int |
| 45 | main() |
| 46 | { |
| 47 | BOOST_STATIC_ASSERT((!phx::stl::has_mapped_type<std::unordered_set<int> >::value)); |
| 48 | BOOST_STATIC_ASSERT((phx::stl::has_key_type<std::unordered_set<int> >::value)); |
| 49 | |
| 50 | std::unordered_set<int> const data = build_unordered_set(); |
| 51 | test_begin(c: data); |
| 52 | test_clear(c: data); |
| 53 | test_empty(c: data); |
| 54 | test_end(c: data); |
| 55 | test_set_erase(c: data); |
| 56 | test_get_allocator(c: data); |
| 57 | return boost::report_errors(); |
| 58 | } |
| 59 | |
| 60 |
