Statistics
| Branch: | Revision:

root / custompackages / graph-parser / src / test / utility.cpp @ 293a61eb

History | View | Annotate | Download (1.14 KB)

1
#define BOOST_TEST_DYN_LINK
2
#define BOOST_TEST_MODULE Utility
3
#include <boost/test/unit_test.hpp>
4
#include "../utility.h"
5

    
6
using namespace boost;
7
using namespace boost::unit_test;
8

    
9
int add(int i, int j)
10
{
11
    return i + j;
12
}
13

    
14
BOOST_AUTO_TEST_CASE(universeInOrder)
15
{
16
    BOOST_CHECK(add(2, 2) == 4);
17
}
18

    
19
BOOST_AUTO_TEST_CASE(stdhelper_exists_for_map)
20
{
21
    std::map<int, int> m;
22
    m[1] = 1;
23
    BOOST_CHECK_EQUAL(stdhelper::exists(m, 1), true);
24
    BOOST_CHECK_EQUAL(stdhelper::exists(m, 2), false);
25

    
26
    std::map<string, int> m2;
27
    string a = "key";
28
    m2[a] = 2;
29
    BOOST_CHECK_EQUAL(stdhelper::exists(m2, a), true);
30

    
31
    m2.erase(a);
32
    BOOST_CHECK_EQUAL(stdhelper::exists(m2, a), false);
33
}
34

    
35
BOOST_AUTO_TEST_CASE(stdhelper_exists_for_set)
36
{
37
    std::set<int> collection;
38
    collection.insert(1);
39
    BOOST_CHECK_EQUAL(stdhelper::exists(collection, 1), true);
40
    BOOST_CHECK_EQUAL(stdhelper::exists(collection, 2), false);
41

    
42
    std::set<string> collection2;
43
    string a = "key";
44
    collection2.insert(a);
45
    BOOST_CHECK_EQUAL(stdhelper::exists(collection2, a), true);
46
    collection2.erase(a);
47
    BOOST_CHECK_EQUAL(stdhelper::exists(collection2, a), false);
48
}