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

Public Member Functions

 LIBMESH_CPPUNIT_TEST_SUITE (VectormapTest)
 
 CPPUNIT_TEST (testCreate)
 
 CPPUNIT_TEST (testInsert)
 
 CPPUNIT_TEST (testEmplace)
 
 CPPUNIT_TEST (testIterate)
 
 CPPUNIT_TEST (testFind)
 
 CPPUNIT_TEST_SUITE_END ()
 
void testCreate ()
 
void testInsert ()
 
void testEmplace ()
 
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 emplace ()
 
template<typename Key , typename Val >
void iterate (const Val &default_value=0)
 

Detailed Description

Definition at line 11 of file vectormap_test.C.

Member Function Documentation

◆ CPPUNIT_TEST() [1/5]

VectormapTest::CPPUNIT_TEST ( testCreate  )

◆ CPPUNIT_TEST() [2/5]

VectormapTest::CPPUNIT_TEST ( testInsert  )

◆ CPPUNIT_TEST() [3/5]

VectormapTest::CPPUNIT_TEST ( testEmplace  )

◆ CPPUNIT_TEST() [4/5]

VectormapTest::CPPUNIT_TEST ( testIterate  )

◆ CPPUNIT_TEST() [5/5]

VectormapTest::CPPUNIT_TEST ( testFind  )

◆ CPPUNIT_TEST_SUITE_END()

VectormapTest::CPPUNIT_TEST_SUITE_END ( )

◆ create()

template<typename Key , typename Val >
void VectormapTest::create ( )
inlineprivate

Definition at line 27 of file vectormap_test.C.

28  {
30  }
This vectormap templated class is intended to provide the performance characteristics of a sorted s...
Definition: vectormap.h:61

◆ emplace()

template<typename Key , typename Val >
void VectormapTest::emplace ( )
inlineprivate

Definition at line 46 of file vectormap_test.C.

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

47  {
49 
50  Val val(0); // requires default constructor for val type.
51 
52  for (Key key=1; key<32; key*=2)
53  vm.emplace(key, val);
54 
55  vm.sort();
56  }
void sort()
Sort & unique the vectormap, preparing for use.
Definition: vectormap.h:136
void emplace(Args &&... args)
Inserts x into the vector map, using "args" to construct it in-place.
Definition: vectormap.h:127
This vectormap templated class is intended to provide the performance characteristics of a sorted s...
Definition: vectormap.h:61

◆ insert()

template<typename Key , typename Val >
void VectormapTest::insert ( )
inlineprivate

Definition at line 33 of file vectormap_test.C.

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

34  {
36 
37  Val val(0); // requires default constructor for val type.
38 
39  for (Key key=1; key<32; key*=2)
40  vm.insert (std::make_pair(key,val));
41 
42  vm.sort();
43  }
void sort()
Sort & unique the vectormap, preparing for use.
Definition: vectormap.h:136
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 s...
Definition: vectormap.h:61

◆ iterate()

template<typename Key , typename Val >
void VectormapTest::iterate ( const Val &  default_value = 0)
inlineprivate

Definition at line 59 of file vectormap_test.C.

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

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

◆ LIBMESH_CPPUNIT_TEST_SUITE()

VectormapTest::LIBMESH_CPPUNIT_TEST_SUITE ( VectormapTest  )

◆ testCreate()

void VectormapTest::testCreate ( )
inline

Definition at line 91 of file vectormap_test.C.

92  {
93  LOG_UNIT_TEST;
94 
95  create<int, int> ();
96  create<int*,int> ();
97  create<int*,int*>();
98  create<int, std::vector<int>>();
99  }

◆ testEmplace()

void VectormapTest::testEmplace ( )
inline

Definition at line 111 of file vectormap_test.C.

112  {
113  LOG_UNIT_TEST;
114 
115  emplace<int, int> ();
116  emplace<char,int> ();
117  emplace<long,int*>();
118  emplace<int, std::vector<int>>();
119  }

◆ testFind()

void VectormapTest::testFind ( )
inline

Definition at line 131 of file vectormap_test.C.

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

132  {
133  LOG_UNIT_TEST;
134 
136  for (int i=16; i<32; ++i)
137  vm.insert(std::make_pair(i,i));
138 
140  it1 = vm.find(24),
141  it2 = vm.find(4);
142 
143  CPPUNIT_ASSERT(it1 != vm.end());
144  CPPUNIT_ASSERT(it2 == vm.end());
145  CPPUNIT_ASSERT(vm.count(24) == 1);
146  CPPUNIT_ASSERT(vm.count(4) == 0);
147  }
iterator find(const key_type &key)
Definition: vectormap.h:171
void insert(const value_type &x)
Inserts x into the vectormap.
Definition: vectormap.h:116
difference_type count(const key_type &key) const
Definition: vectormap.h:221
vector_type::iterator iterator
Definition: vectormap.h:71
This vectormap templated class is intended to provide the performance characteristics of a sorted s...
Definition: vectormap.h:61

◆ testInsert()

void VectormapTest::testInsert ( )
inline

Definition at line 101 of file vectormap_test.C.

102  {
103  LOG_UNIT_TEST;
104 
105  insert<int, int> ();
106  insert<char,int> ();
107  insert<long,int*>();
108  insert<int, std::vector<int>>();
109  }

◆ testIterate()

void VectormapTest::testIterate ( )
inline

Definition at line 121 of file vectormap_test.C.

122  {
123  LOG_UNIT_TEST;
124 
125  iterate<int, int> ();
126  iterate<char,int> ();
127  iterate<long,int*>();
128  iterate<int, std::string>("test_string");
129  }

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