libMesh
Public Member Functions | Private Member Functions | List of all members
VectormapTest Class Reference
Inheritance diagram for VectormapTest:
[legend]

Public Member Functions

 CPPUNIT_TEST_SUITE (VectormapTest)
 
 CPPUNIT_TEST (testCreate)
 
 CPPUNIT_TEST (testInsert)
 
 CPPUNIT_TEST (testIterate)
 
 CPPUNIT_TEST (testFind)
 
 CPPUNIT_TEST_SUITE_END ()
 
void testCreate ()
 
void testInsert ()
 
void testIterate ()
 
void testFind ()
 

Private Member Functions

template<typename Key , typename Val >
void create ()
 
template<typename Key , typename Val >
void insert ()
 
template<typename Key , typename Val >
void iterate (const Val &default_value=0)
 

Detailed Description

Definition at line 24 of file vectormap_test.C.

Member Function Documentation

VectormapTest::CPPUNIT_TEST ( testCreate  )
VectormapTest::CPPUNIT_TEST ( testInsert  )
VectormapTest::CPPUNIT_TEST ( testIterate  )
VectormapTest::CPPUNIT_TEST ( testFind  )
VectormapTest::CPPUNIT_TEST_SUITE ( VectormapTest  )
VectormapTest::CPPUNIT_TEST_SUITE_END ( )
template<typename Key , typename Val >
void VectormapTest::create ( )
private

Definition at line 39 of file vectormap_test.C.

40  {
42  }
This vectormap templated class is intended to provide the performance characteristics of a sorted std...
Definition: vectormap.h:61
template<typename Key , typename Val >
void VectormapTest::insert ( )
private

Definition at line 45 of file vectormap_test.C.

References libMesh::vectormap< Key, Tp >::insert(), and libMesh::vectormap< Key, Tp >::sort().

46  {
48 
49  Val val(0); // requires default constructor for val type.
50 
51  for (Key key=1; key<32; key*=2)
52  vm.insert (std::make_pair(key,val));
53 
54  vm.sort();
55  }
void sort()
Sort & unique the vectormap, preparing for use.
Definition: vectormap.h:125
void insert(const value_type &x)
Inserts x into the vectormap.
Definition: vectormap.h:116
This vectormap templated class is intended to provide the performance characteristics of a sorted std...
Definition: vectormap.h:61
template<typename Key , typename Val >
void VectormapTest::iterate ( const Val &  default_value = 0)
private

Definition at line 58 of file vectormap_test.C.

References libMesh::vectormap< Key, Tp >::count(), libMesh::vectormap< Key, Tp >::insert(), and libMesh::vectormap< Key, Tp >::sort().

59  {
61 
62  Val val(default_value); // requires default constructor for val type.
63 
64  for (Key key=1; key<32; key*=2)
65  vm.insert (std::make_pair(key,val));
66 
67  vm.sort();
68 
69  for (typename vectormap<Key,Val>::const_iterator it=vm.begin();
70  it != vm.end(); ++it)
71  {
72  const Key &ikey = it->first;
73  const Val &ival = it->second;
74 
75  CPPUNIT_ASSERT ( vm.count(ikey) == 1 );
76  CPPUNIT_ASSERT_EQUAL (vm[ikey], ival);
77  CPPUNIT_ASSERT_EQUAL (ival, val);
78  }
79  }
difference_type count(const key_type &key) const
Definition: vectormap.h:210
vector_type::const_iterator const_iterator
Definition: vectormap.h:72
void sort()
Sort & unique the vectormap, preparing for use.
Definition: vectormap.h:125
void insert(const value_type &x)
Inserts x into the vectormap.
Definition: vectormap.h:116
This vectormap templated class is intended to provide the performance characteristics of a sorted std...
Definition: vectormap.h:61
void VectormapTest::testCreate ( )

Definition at line 90 of file vectormap_test.C.

91  {
92  create<int, int> ();
93  create<int*,int> ();
94  create<int*,int*>();
95  create<int, std::vector<int>>();
96  }
void VectormapTest::testFind ( )

Definition at line 114 of file vectormap_test.C.

References libMesh::vectormap< Key, Tp >::count(), CPPUNIT_TEST_SUITE_REGISTRATION(), libMesh::vectormap< Key, Tp >::find(), and libMesh::vectormap< Key, Tp >::insert().

115  {
117  for (int i=16; i<32; ++i)
118  vm.insert(std::make_pair(i,i));
119 
121  it1 = vm.find(24),
122  it2 = vm.find(4);
123 
124  CPPUNIT_ASSERT(it1 != vm.end());
125  CPPUNIT_ASSERT(it2 == vm.end());
126  CPPUNIT_ASSERT(vm.count(24) == 1);
127  CPPUNIT_ASSERT(vm.count(4) == 0);
128  }
iterator find(const key_type &key)
Definition: vectormap.h:160
difference_type count(const key_type &key) const
Definition: vectormap.h:210
void insert(const value_type &x)
Inserts x into the vectormap.
Definition: vectormap.h:116
vector_type::iterator iterator
Definition: vectormap.h:71
This vectormap templated class is intended to provide the performance characteristics of a sorted std...
Definition: vectormap.h:61
void VectormapTest::testInsert ( )

Definition at line 98 of file vectormap_test.C.

99  {
100  insert<int, int> ();
101  insert<char,int> ();
102  insert<long,int*>();
103  insert<int, std::vector<int>>();
104  }
void VectormapTest::testIterate ( )

Definition at line 106 of file vectormap_test.C.

107  {
108  iterate<int, int> ();
109  iterate<char,int> ();
110  iterate<long,int*>();
111  iterate<int, std::string>("test_string");
112  }

The documentation for this class was generated from the following file: