Line data Source code
1 : //
2 : // Author: Vladimir Migashko <migashko@gmail.com>, (C) 2012
3 : //
4 : // Copyright: See COPYING file that comes with this distribution
5 : //
6 :
7 : #include <vset/multiset.hpp>
8 : #include <vset/allocators/mmap_allocator.hpp>
9 : #include <fas/testing.hpp>
10 :
11 3 : UNIT(multiset_mmap, "")
12 : {
13 : using namespace fas::testing;
14 : using namespace vset;
15 :
16 : typedef multiset<int, std::greater<int>, mmap_allocator<512> > multiset_type;
17 1 : multiset_type int_set;
18 :
19 1 : int_set.get_allocator().memory().buffer().open("./multiset_mmap.bin");
20 1 : int_set.clear();
21 :
22 1 : int_set.insert(1);
23 1 : int_set.insert(1);
24 1 : int_set.insert(1);
25 :
26 1 : int_set.insert(2);
27 1 : int_set.insert(2);
28 1 : int_set.insert(2);
29 :
30 :
31 1 : t << equal<expect, size_t>( int_set.size(), 6) << FAS_TESTING_FILE_LINE;
32 :
33 1 : multiset_type::iterator itr = int_set.find(2);
34 :
35 1 : int_set.erase(itr);
36 1 : itr+=-1;
37 :
38 1 : t << equal<expect, size_t>( int_set.size(), 5) << FAS_TESTING_FILE_LINE;
39 :
40 1 : int_set.erase(1);
41 :
42 1 : t << equal<expect, size_t>( int_set.size(), 2) << FAS_TESTING_FILE_LINE;
43 :
44 1 : int_set.clear();
45 :
46 1 : t << nothing;
47 1 : }
48 :
49 1 : BEGIN_SUITE(multiset_mmap_suite, "")
50 : #if ( ! (__GNUC__==4 && __GNUC_MINOR__==6) )
51 : ADD_UNIT(multiset_mmap)
52 : #endif
53 7 : END_SUITE(multiset_mmap_suite)
|