Revision 293a61eb

View differences:

custompackages/graph-parser/src/test/Makefile
1
TARGETS=utility
2

  
3
all: $(TARGETS)
4

  
5
test: $(TARGETS) $(addprefix run-,$(TARGETS))
6

  
7
%: %.cpp
8
	$(CXX) $(CFLAGS) -o$@ $^ -lboost_unit_test_framework
9

  
10
run-%: %
11
	-./$^ --output_format=XML --log_level=test_suite > $(^)-report.xml
12

  
13
clean:
14
	rm $(TARGETS) *-report.xml
custompackages/graph-parser/src/test/utility.cpp
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
}

Also available in: Unified diff