1#include "libmesh/vectormap.h"
6#define VECTORMAPOBJECTTEST \
7 CPPUNIT_TEST( testCreate ); \
26 template <
typename Key,
typename Val>
32 template <
typename Key,
typename Val>
39 for (Key key=1; key<32; key*=2)
40 vm.
insert (std::make_pair(key,val));
45 template <
typename Key,
typename Val>
52 for (Key key=1; key<32; key*=2)
58 template <
typename Key,
typename Val>
63 Val val(default_value);
65 for (Key key=1; key<32; key*=2)
66 vm.
insert (std::make_pair(key,val));
73 const Key &ikey = it->first;
74 const Val &ival = it->second;
76 CPPUNIT_ASSERT ( vm.
count(ikey) == 1 );
77 CPPUNIT_ASSERT_EQUAL (vm[ikey], ival);
78 CPPUNIT_ASSERT_EQUAL (ival, val);
98 create<int, std::vector<int>>();
108 insert<int, std::vector<int>>();
115 emplace<int, int> ();
116 emplace<char,int> ();
117 emplace<long,int*>();
118 emplace<int, std::vector<int>>();
125 iterate<int, int> ();
126 iterate<char,int> ();
127 iterate<long,int*>();
128 iterate<int, std::string>(
"test_string");
136 for (
int i=16; i<32; ++i)
137 vm.
insert(std::make_pair(i,i));
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);
void iterate(const Val &default_value=0)
CPPUNIT_TEST(testIterate)
LIBMESH_CPPUNIT_TEST_SUITE(VectormapTest)
CPPUNIT_TEST(testEmplace)
This vectormap templated class is intended to provide the performance characteristics of a sorted std...
void insert(const value_type &x)
Inserts x into the vectormap.
difference_type count(const key_type &key) const
vector_type::const_iterator const_iterator
void emplace(Args &&... args)
Inserts x into the vector map, using "args" to construct it in-place.
void sort()
Sort & unique the vectormap, preparing for use.
iterator find(const key_type &key)
vector_type::iterator iterator
The libMesh namespace provides an interface to certain functionality in the library.
CPPUNIT_TEST_SUITE_REGISTRATION(VectormapTest)