PageRenderTime 19ms CodeModel.GetById 2ms app.highlight 14ms RepoModel.GetById 2ms app.codeStats 0ms

/Src/Dependencies/Boost/libs/unordered/test/unordered/compile_map.cpp

http://hadesmem.googlecode.com/
C++ | 177 lines | 128 code | 43 blank | 6 comment | 0 complexity | 90001c3cab5a28b730014e5fd4c61b2d MD5 | raw file
  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// This test creates the containers with members that meet their minimum
  7// requirements. Makes sure everything compiles and is defined correctly.
  8
  9#include "../helpers/prefix.hpp"
 10
 11#include <boost/unordered_map.hpp>
 12
 13#include <iostream>
 14#include "../helpers/test.hpp"
 15#include "../objects/minimal.hpp"
 16#include "./compile_tests.hpp"
 17
 18// Explicit instantiation to catch compile-time errors
 19
 20template class boost::unordered_map<
 21    test::minimal::assignable,
 22    test::minimal::default_copy_constructible,
 23    test::minimal::hash<test::minimal::assignable>,
 24    test::minimal::equal_to<test::minimal::assignable>,
 25    test::minimal::allocator<test::minimal::assignable> >;
 26template class boost::unordered_multimap<
 27    test::minimal::assignable,
 28    test::minimal::copy_constructible,
 29    test::minimal::hash<test::minimal::assignable>,
 30    test::minimal::equal_to<test::minimal::assignable>,
 31    test::minimal::allocator<test::minimal::assignable> >;
 32
 33UNORDERED_AUTO_TEST(test0)
 34{
 35    typedef std::pair<test::minimal::assignable const,
 36            test::minimal::copy_constructible> value_type;
 37    value_type value(
 38            test::minimal::assignable::create(),
 39            test::minimal::copy_constructible::create());
 40
 41    std::cout<<"Test unordered_map.\n";
 42
 43    boost::unordered_map<int, int> int_map;
 44
 45    boost::unordered_map<
 46        test::minimal::assignable,
 47        test::minimal::copy_constructible,
 48        test::minimal::hash<test::minimal::assignable>,
 49        test::minimal::equal_to<test::minimal::assignable>,
 50        test::minimal::allocator<value_type> > map;
 51
 52    container_test(int_map, std::pair<int const, int>(0, 0));
 53    container_test(map, value);
 54
 55    std::cout<<"Test unordered_multimap.\n";
 56
 57    boost::unordered_multimap<int, int> int_multimap;
 58
 59    boost::unordered_multimap<
 60        test::minimal::assignable,
 61        test::minimal::copy_constructible,
 62        test::minimal::hash<test::minimal::assignable>,
 63        test::minimal::equal_to<test::minimal::assignable>,
 64        test::minimal::allocator<value_type> > multimap;
 65
 66    container_test(int_multimap, std::pair<int const, int>(0, 0));
 67    container_test(multimap, value);
 68}
 69
 70UNORDERED_AUTO_TEST(equality_tests) {
 71    typedef std::pair<test::minimal::assignable const,
 72            test::minimal::copy_constructible> value_type;
 73
 74    boost::unordered_map<int, int> int_map;
 75
 76    boost::unordered_map<
 77        test::minimal::assignable,
 78        test::minimal::copy_constructible_equality_comparable,
 79        test::minimal::hash<test::minimal::assignable>,
 80        test::minimal::equal_to<test::minimal::assignable>,
 81        test::minimal::allocator<value_type> > map;
 82
 83    equality_test(int_map);
 84    equality_test(map);
 85
 86    boost::unordered_multimap<int, int> int_multimap;
 87
 88    boost::unordered_multimap<
 89        test::minimal::assignable,
 90        test::minimal::copy_constructible_equality_comparable,
 91        test::minimal::hash<test::minimal::assignable>,
 92        test::minimal::equal_to<test::minimal::assignable>,
 93        test::minimal::allocator<value_type> > multimap;
 94
 95    equality_test(int_multimap);
 96    equality_test(multimap);
 97}
 98
 99UNORDERED_AUTO_TEST(test1) {
100    boost::hash<int> hash;
101    std::equal_to<int> equal_to;
102    int value = 0;
103    std::pair<int const, int> map_value(0, 0);
104
105    std::cout<<"Test unordered_map.\n";
106
107    boost::unordered_map<int, int> map;
108
109    unordered_unique_test(map, map_value);
110    unordered_map_test(map, value, value);
111    unordered_test(map, value, map_value, hash, equal_to);
112    unordered_map_functions(map, value, value);
113
114    std::cout<<"Test unordered_multimap.\n";
115
116    boost::unordered_multimap<int, int> multimap;
117
118    unordered_equivalent_test(multimap, map_value);
119    unordered_map_test(multimap, value, value);
120    unordered_test(multimap, value, map_value, hash, equal_to);
121}
122
123UNORDERED_AUTO_TEST(test2)
124{
125    test::minimal::assignable assignable
126        = test::minimal::assignable::create();
127    test::minimal::copy_constructible copy_constructible
128        = test::minimal::copy_constructible::create();
129    test::minimal::hash<test::minimal::assignable> hash
130        = test::minimal::hash<test::minimal::assignable>::create();
131    test::minimal::equal_to<test::minimal::assignable> equal_to
132        = test::minimal::equal_to<test::minimal::assignable>::create();
133
134    typedef std::pair<test::minimal::assignable const,
135            test::minimal::copy_constructible> map_value_type;
136    map_value_type map_value(assignable, copy_constructible);
137
138    std::cout<<"Test unordered_map.\n";
139
140    boost::unordered_map<
141        test::minimal::assignable,
142        test::minimal::copy_constructible,
143        test::minimal::hash<test::minimal::assignable>,
144        test::minimal::equal_to<test::minimal::assignable>,
145        test::minimal::allocator<map_value_type> > map;
146
147    unordered_unique_test(map, map_value);
148    unordered_map_test(map, assignable, copy_constructible);
149    unordered_test(map, assignable, map_value, hash, equal_to);
150
151
152    boost::unordered_map<
153        test::minimal::assignable,
154        test::minimal::default_copy_constructible,
155        test::minimal::hash<test::minimal::assignable>,
156        test::minimal::equal_to<test::minimal::assignable>,
157        test::minimal::allocator<map_value_type> > map2;
158
159    test::minimal::default_copy_constructible default_copy_constructible;
160
161    unordered_map_functions(map2, assignable, default_copy_constructible);
162
163    std::cout<<"Test unordered_multimap.\n";
164
165    boost::unordered_multimap<
166        test::minimal::assignable,
167        test::minimal::copy_constructible,
168        test::minimal::hash<test::minimal::assignable>,
169        test::minimal::equal_to<test::minimal::assignable>,
170        test::minimal::allocator<map_value_type> > multimap;
171
172    unordered_equivalent_test(multimap, map_value);
173    unordered_map_test(multimap, assignable, copy_constructible);
174    unordered_test(multimap, assignable, map_value, hash, equal_to);
175}
176
177RUN_TESTS()