-
Notifications
You must be signed in to change notification settings - Fork 0
/
testmain.cpp
73 lines (51 loc) · 1.66 KB
/
testmain.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*
* Unit-test drivers for BpoModes
*/
#include <boost/algorithm/string.hpp>
#include <boost/test/unit_test.hpp>
#include "testdefns.hpp"
namespace bpomodes {
namespace testing {
std::vector<std::string> TestSuite::split(const std::string& line) {
std::vector<std::string> args;
boost::split(args, line, boost::is_any_of(" \t"),
boost::algorithm::token_compress_on);
return args;
}
void TestSuite::check_vm_keys(const BoostPO::variables_map& vm,
const std::set<std::string>& expected) {
std::set<std::string> observed;
for (auto kv : vm) observed.insert(kv.first);
BOOST_CHECK_EQUAL_COLLECTIONS(observed.cbegin(), observed.cend(),
expected.cbegin(), expected.cend());
}
struct RootSuite : TestSuite {
RootSuite()
: TestSuite("bpomodes tests")
{
add(BOOST_TEST_CASE(splitting));
add(new TestBare);
add(new TestModes);
add(new TestModeAPI);
}
static void splitting() {
const auto result = split("alpha beta gamma \t \t delta");
const std::vector<std::string> expected { "alpha", "beta", "gamma", "delta" };
BOOST_CHECK_EQUAL_COLLECTIONS(result.cbegin(), result.cend(),
expected.cbegin(), expected.cend());
}
};
//! Unit-test initialization mechanism for boost::unit_test
bool init_unit_test_suite()
{
BoostUT::framework::master_test_suite().add(new RootSuite);
return true;
}
} // namespace testing
} // namespace rtimers
int main(int argc, char *argv[])
{
return BoostUT::unit_test_main(
(BoostUT::init_unit_test_func)bpomodes::testing::init_unit_test_suite,
argc, argv);
}