File: test_capacity.cpp

package info (click to toggle)
boost 1.33.1-10
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 100,948 kB
  • ctags: 145,103
  • sloc: cpp: 573,492; xml: 49,055; python: 15,626; ansic: 13,588; sh: 2,099; yacc: 858; makefile: 660; perl: 427; lex: 111; csh: 6
file content (55 lines) | stat: -rw-r--r-- 1,524 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/* Boost.MultiIndex test for capacity memfuns.
 *
 * Copyright 2003-2005 Joaqun M Lpez Muoz.
 * Distributed under the Boost Software License, Version 1.0.
 * (See accompanying file LICENSE_1_0.txt or copy at
 * http://www.boost.org/LICENSE_1_0.txt)
 *
 * See http://www.boost.org/libs/multi_index for library home page.
 */

#include "test_capacity.hpp"

#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
#include "pre_multi_index.hpp"
#include "employee.hpp"
#include <boost/test/test_tools.hpp>

using namespace boost::multi_index;

void test_capacity()
{
  employee_set es;

  es.insert(employee(0,"Joe",31,1123));
  es.insert(employee(1,"Robert",27,5601));
  es.insert(employee(2,"John",40,7889));
  es.insert(employee(3,"Albert",20,9012));
  es.insert(employee(4,"John",57,1002));

  BOOST_CHECK(!es.empty());
  BOOST_CHECK(es.size()==5);
  BOOST_CHECK(es.size()<=es.max_size());

  es.erase(es.begin());
  BOOST_CHECK(!get<name>(es).empty());
  BOOST_CHECK(get<name>(es).size()==4);
  BOOST_CHECK(get<name>(es).size()<=get<name>(es).max_size());

  es.erase(es.begin());
  BOOST_CHECK(!get<as_inserted>(es).empty());
  BOOST_CHECK(get<as_inserted>(es).size()==3);
  BOOST_CHECK(get<as_inserted>(es).size()<=get<as_inserted>(es).max_size());

  multi_index_container<int,indexed_by<sequenced<> > > ss;

  ss.resize(10);
  BOOST_CHECK(ss.size()==10);
  BOOST_CHECK(ss.size()<=ss.max_size());

  ss.resize(20);
  BOOST_CHECK(ss.size()==20);

  ss.resize(5);
  BOOST_CHECK(ss.size()==5);
}