PageRenderTime 19ms CodeModel.GetById 1ms app.highlight 15ms RepoModel.GetById 1ms app.codeStats 0ms

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

http://hadesmem.googlecode.com/
C++ | 143 lines | 103 code | 34 blank | 6 comment | 0 complexity | c7b0d36ce1cbf397716c01644fa3ccf3 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_set.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_set<
 21    test::minimal::assignable,
 22    test::minimal::hash<test::minimal::assignable>,
 23    test::minimal::equal_to<test::minimal::assignable>,
 24    test::minimal::allocator<test::minimal::assignable> >;
 25template class boost::unordered_multiset<
 26    test::minimal::assignable,
 27    test::minimal::hash<test::minimal::assignable>,
 28    test::minimal::equal_to<test::minimal::assignable>,
 29    test::minimal::allocator<test::minimal::assignable> >;
 30
 31UNORDERED_AUTO_TEST(test0)
 32{
 33    test::minimal::assignable assignable = test::minimal::assignable::create();
 34
 35    std::cout<<"Test unordered_set.\n";
 36    boost::unordered_set<int> int_set;
 37    boost::unordered_set<
 38        test::minimal::assignable,
 39        test::minimal::hash<test::minimal::assignable>,
 40        test::minimal::equal_to<test::minimal::assignable>,
 41        test::minimal::allocator<test::minimal::assignable> > set;
 42
 43    container_test(int_set, 0);
 44    container_test(set, assignable);
 45
 46    std::cout<<"Test unordered_multiset.\n";
 47    boost::unordered_multiset<int> int_multiset;
 48    boost::unordered_multiset<
 49        test::minimal::assignable,
 50        test::minimal::hash<test::minimal::assignable>,
 51        test::minimal::equal_to<test::minimal::assignable>,
 52        test::minimal::allocator<test::minimal::assignable> > multiset;
 53
 54    container_test(int_multiset, 0);
 55    container_test(multiset, assignable);
 56}
 57
 58UNORDERED_AUTO_TEST(equality_tests) {
 59    typedef test::minimal::assignable value_type;
 60
 61    boost::unordered_set<int> int_set;
 62
 63    boost::unordered_set<
 64        test::minimal::assignable,
 65        test::minimal::hash<test::minimal::assignable>,
 66        test::minimal::equal_to<test::minimal::assignable>,
 67        test::minimal::allocator<value_type> > set;
 68
 69    equality_test(int_set);
 70    equality_test(set);
 71
 72    boost::unordered_multiset<int> int_multiset;
 73
 74    boost::unordered_multiset<
 75        test::minimal::assignable,
 76        test::minimal::hash<test::minimal::assignable>,
 77        test::minimal::equal_to<test::minimal::assignable>,
 78        test::minimal::allocator<value_type> > multiset;
 79
 80    equality_test(int_multiset);
 81    equality_test(multiset);
 82}
 83
 84UNORDERED_AUTO_TEST(test1)
 85{
 86    boost::hash<int> hash;
 87    std::equal_to<int> equal_to;
 88    int value = 0;
 89
 90    std::cout<<"Test unordered_set.\n";
 91
 92    boost::unordered_set<int> set;
 93    
 94    unordered_unique_test(set, value);
 95    unordered_set_test(set, value);
 96    unordered_test(set, value, value, hash, equal_to);
 97
 98    std::cout<<"Test unordered_multiset.\n";
 99
100    boost::unordered_multiset<int> multiset;
101    
102    unordered_equivalent_test(multiset, value);
103    unordered_set_test(multiset, value);
104    unordered_test(multiset, value, value, hash, equal_to);
105}
106
107UNORDERED_AUTO_TEST(test2)
108{
109    test::minimal::assignable assignable
110        = test::minimal::assignable::create();
111    test::minimal::copy_constructible copy_constructible
112        = test::minimal::copy_constructible::create();
113    test::minimal::hash<test::minimal::assignable> hash
114        = test::minimal::hash<test::minimal::assignable>::create();
115    test::minimal::equal_to<test::minimal::assignable> equal_to
116        = test::minimal::equal_to<test::minimal::assignable>::create();
117
118    std::cout<<"Test unordered_set.\n";
119
120    boost::unordered_set<
121        test::minimal::assignable,
122        test::minimal::hash<test::minimal::assignable>,
123        test::minimal::equal_to<test::minimal::assignable>,
124        test::minimal::allocator<test::minimal::assignable> > set;
125
126    unordered_unique_test(set, assignable);
127    unordered_set_test(set, assignable);
128    unordered_test(set, assignable, assignable, hash, equal_to);
129
130    std::cout<<"Test unordered_multiset.\n";
131
132    boost::unordered_multiset<
133        test::minimal::assignable,
134        test::minimal::hash<test::minimal::assignable>,
135        test::minimal::equal_to<test::minimal::assignable>,
136        test::minimal::allocator<test::minimal::assignable> > multiset;
137
138    unordered_equivalent_test(multiset, assignable);
139    unordered_set_test(multiset, assignable);
140    unordered_test(multiset, assignable, assignable, hash, equal_to);
141}
142
143RUN_TESTS()