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 11 of file vectormap_test.C.

Member Function Documentation

◆ CPPUNIT_TEST() [1/4]

VectormapTest::CPPUNIT_TEST ( testCreate  )

◆ CPPUNIT_TEST() [2/4]

VectormapTest::CPPUNIT_TEST ( testFind  )

◆ CPPUNIT_TEST() [3/4]

VectormapTest::CPPUNIT_TEST ( testInsert  )

◆ CPPUNIT_TEST() [4/4]

VectormapTest::CPPUNIT_TEST ( testIterate  )

◆ CPPUNIT_TEST_SUITE()

VectormapTest::CPPUNIT_TEST_SUITE ( VectormapTest  )

◆ CPPUNIT_TEST_SUITE_END()

VectormapTest::CPPUNIT_TEST_SUITE_END ( )

◆ create()

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

Definition at line 26 of file vectormap_test.C.

27  {
29  }

◆ insert()

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

Definition at line 32 of file vectormap_test.C.

33  {
35 
36  Val val(0); // requires default constructor for val type.
37 
38  for (Key key=1; key<32; key*=2)
39  vm.insert (std::make_pair(key,val));
40 
41  vm.sort();
42  }

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

◆ iterate()

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

Definition at line 45 of file vectormap_test.C.

46  {
48 
49  Val val(default_value); // 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 
56  for (typename vectormap<Key,Val>::const_iterator it=vm.begin();
57  it != vm.end(); ++it)
58  {
59  const Key &ikey = it->first;
60  const Val &ival = it->second;
61 
62  CPPUNIT_ASSERT ( vm.count(ikey) == 1 );
63  CPPUNIT_ASSERT_EQUAL (vm[ikey], ival);
64  CPPUNIT_ASSERT_EQUAL (ival, val);
65  }
66  }

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

◆ testCreate()

void VectormapTest::testCreate ( )
inline

Definition at line 77 of file vectormap_test.C.

78  {
79  create<int, int> ();
80  create<int*,int> ();
81  create<int*,int*>();
82  create<int, std::vector<int>>();
83  }

◆ testFind()

void VectormapTest::testFind ( )
inline

Definition at line 101 of file vectormap_test.C.

102  {
104  for (int i=16; i<32; ++i)
105  vm.insert(std::make_pair(i,i));
106 
108  it1 = vm.find(24),
109  it2 = vm.find(4);
110 
111  CPPUNIT_ASSERT(it1 != vm.end());
112  CPPUNIT_ASSERT(it2 == vm.end());
113  CPPUNIT_ASSERT(vm.count(24) == 1);
114  CPPUNIT_ASSERT(vm.count(4) == 0);
115  }

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

◆ testInsert()

void VectormapTest::testInsert ( )
inline

Definition at line 85 of file vectormap_test.C.

86  {
87  insert<int, int> ();
88  insert<char,int> ();
89  insert<long,int*>();
90  insert<int, std::vector<int>>();
91  }

◆ testIterate()

void VectormapTest::testIterate ( )
inline

Definition at line 93 of file vectormap_test.C.

94  {
95  iterate<int, int> ();
96  iterate<char,int> ();
97  iterate<long,int*>();
98  iterate<int, std::string>("test_string");
99  }

The documentation for this class was generated from the following file:
libMesh::vectormap
This vectormap templated class is intended to provide the performance characteristics of a sorted std...
Definition: vectormap.h:61
libMesh::vectormap::const_iterator
vector_type::const_iterator const_iterator
Definition: vectormap.h:72
libMesh::vectormap::count
difference_type count(const key_type &key) const
Definition: vectormap.h:210
libMesh::vectormap::find
iterator find(const key_type &key)
Definition: vectormap.h:160
libMesh::vectormap::iterator
vector_type::iterator iterator
Definition: vectormap.h:71
libMesh::vectormap::insert
void insert(const value_type &x)
Inserts x into the vectormap.
Definition: vectormap.h:116
libMesh::vectormap::sort
void sort()
Sort & unique the vectormap, preparing for use.
Definition: vectormap.h:125