Ticket #4814: test_initializer_list.cpp

File test_initializer_list.cpp, 1.2 KB (added by Akira Takahashi <faithandbrave@…>, 12 years ago)

test code

Line 
1#include <boost/detail/lightweight_test.hpp>
2#include <boost/config.hpp>
3#include <vector>
4
5#include <boost/multi_index_container.hpp>
6#include <boost/multi_index/ordered_index.hpp>
7#include <boost/multi_index/hashed_index.hpp>
8#include <boost/multi_index/random_access_index.hpp>
9#include <boost/multi_index/sequenced_index.hpp>
10#include <boost/range/algorithm/equal.hpp>
11
12struct ord_tag {};
13struct hash_tag {};
14struct rand_tag {};
15struct seq_tag {};
16
17using namespace boost::multi_index;
18typedef multi_index_container<
19 int,
20 indexed_by<
21 ordered_unique<tag<ord_tag>, identity<int> >,
22 hashed_unique<tag<hash_tag>, identity<int> >,
23 random_access<tag<rand_tag> >,
24 sequenced<tag<seq_tag> >
25 >
26> container;
27
28#if defined(BOOST_NO_INITIALIZER_LISTS)
29int main() {}
30#else
31int main()
32{
33 const container c = {3, 1, 4};
34 {
35 const std::vector<int> expected = {1, 3, 4};
36 BOOST_TEST(boost::equal(c, expected));
37 BOOST_TEST(boost::equal(c.get<ord_tag>(), expected));
38 BOOST_TEST(boost::equal(c.get<hash_tag>(), expected));
39 }
40 {
41 const std::vector<int> expected = {3, 1, 4};
42 BOOST_TEST(boost::equal(c.get<rand_tag>(), expected));
43 BOOST_TEST(boost::equal(c.get<seq_tag>(), expected));
44 }
45 return boost::report_errors();
46}
47#endif
48