forked from valhalla/valhalla
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfiguration.cc
51 lines (38 loc) · 948 Bytes
/
configuration.cc
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
#include "test.h"
#include <string>
#include "config.h"
namespace {
TEST(Configuration, UseBeforeConfiguration) {
EXPECT_ANY_THROW(valhalla::config());
}
TEST(Configuration, ReadInlineConfig) {
using namespace valhalla;
auto inline_config = R"(
{
"obj1": {
"val": "example"
},
"obj2": {
"inner": {
"val": 4
}
}
}
)";
auto conf = config(inline_config);
EXPECT_EQ(conf.get<std::string>("obj1.val"), "example");
EXPECT_EQ(conf.get<uint32_t>("obj2.inner.val"), 4);
}
TEST(Configuration, OneInstanceExisting) {
using namespace valhalla;
auto inline_config_1 = "{'key1': 'val1'}";
auto inline_config_2 = "{'key2': 'val2'}";
auto conf1 = &config(inline_config_1);
auto conf2 = &config(inline_config_2);
EXPECT_EQ(conf1, conf2);
}
} // namespace
int main(int argc, char* argv[]) {
testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}