7 #define BOOST_TEST_DYN_LINK
8 #define BOOST_TEST_MODULE "Test module for Map component"
10 #include <boost/test/unit_test.hpp>
40 BOOST_FIXTURE_TEST_SUITE( MapTests,
MapFixture )
51 BOOST_CHECK_EQUAL(map.
type_name() ,
"Map<string,unsigned>");
53 BOOST_CHECK(map.
find(
"first") == map.
end());
56 BOOST_CHECK_EQUAL(map.
size() , 1u);
57 BOOST_CHECK_EQUAL(map[
"first"] , 1u);
59 BOOST_CHECK_EQUAL(map.
size() , 2u);
60 BOOST_CHECK_EQUAL(map[
"second"] , 2u);
62 BOOST_CHECK_EQUAL(map.
size() , 3u);
63 BOOST_CHECK_EQUAL(map[
"third"] , 3u);
65 BOOST_CHECK(map.
find(
"fourth") == map.
end());
67 BOOST_CHECK_EQUAL(map.find(
"fourth")->second,4u);
68 BOOST_CHECK_EQUAL(map.size() , 4u);
88 BOOST_CHECK_EQUAL( map[key] , data );
90 std::pair<Map<std::string,Uint>::iterator,
bool> ret;
91 ret = map.
insert(std::make_pair(
"fifth",5u));
92 BOOST_CHECK_EQUAL(ret.second,
true);
93 BOOST_CHECK_EQUAL(ret.first->first,
"fifth");
94 BOOST_CHECK_EQUAL(ret.first->second, 5u);
97 ret = map.
insert(std::make_pair(
"fifth",1000));
98 BOOST_CHECK_EQUAL(ret.second,
false);
99 BOOST_CHECK_EQUAL(ret.first->first,
"fifth");
100 BOOST_CHECK_EQUAL(ret.first->second, 5u);
102 BOOST_CHECK(map.
erase(
"first"));
103 BOOST_CHECK(map.
find(
"first") == map.
end());
106 BOOST_CHECK(map.
find(
"fourth") == map.
end());
109 BOOST_CHECK(const_map.find(
"second") != const_map.end());
119 BOOST_CHECK_EQUAL(map.
type_name() ,
"Map<integer,integer>");
144 BOOST_CHECK_EQUAL(map.
type_name() ,
"Map<string,integer>");
147 std::map<std::string,int> stl_map;
148 stl_map[
"first"] = 1;
149 stl_map[
"second"] = 2;
150 stl_map[
"third"] = 3;
151 stl_map[
"fourth"] = 4;
154 BOOST_CHECK_EQUAL(map.
size(), 4u);
155 BOOST_CHECK_EQUAL(map[
"third"], 3);
161 BOOST_AUTO_TEST_SUITE_END()
static std::string type_name()
Get the class name.
void erase(iterator itr)
Erase the given iterator from the map.
BOOST_AUTO_TEST_CASE(test_Map)
#define foreach_container(VARS, COL)
boost_foreach version that allows to use std::map's, boost::tuple's, std::pair's internal variables ...
MapFixture()
common setup for each test case
void copy_std_map(std::map< key_type, data_type > &map)
Copy a std::map into the Map.
~MapFixture()
common tear-down for each test case
Top-level namespace for coolfluid.
iterator find(const key_type &key)
Find the iterator matching with the given KEY.
void sort_keys()
Sort all the pairs in the map by key.
unsigned int Uint
typedef for unsigned int
std::pair< iterator, bool > insert(const value_type &v)
Insert pair the same way a std::map would.
coolfluid3 header, included almost everywhere
void map(Field &field, Eigen::Map< Derived > &v, const Uint row_idx, const Uint var_idx)
Uint push_back(const key_type &key, const data_type &data)
Insert pair without any checks if it is already present.
Most basic kernel library.
boost::shared_ptr< T > allocate_component(const std::string &name)
Stand-alone function to allocate components of a given type.
size_t size() const
Get the number of pairs already inserted.