-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcheck_paths.cpp
More file actions
80 lines (66 loc) · 2.15 KB
/
Copy pathcheck_paths.cpp
File metadata and controls
80 lines (66 loc) · 2.15 KB
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
74
75
76
77
78
79
80
#include <gtest/gtest.h>
#include "parser/config_reader/config_node.hpp"
#include "parser/config_reader/config_node_with_preset.hpp"
namespace sim {
namespace test2 {
TEST(PathConfigNode, NoPath) {
YAML::Node root = YAML::Load(R"(
a:
b:
c: 1
)");
ConfigNode node(root, std::nullopt);
auto a = node["a"].value();
auto b = a["b"].value();
auto c = b["c"].value();
ASSERT_EQ(b.get_config_path(), std::nullopt);
ASSERT_EQ(c.get_config_path(), std::nullopt);
}
TEST(PathConfigNode, PathExists) {
std::filesystem::path check_path =
std::filesystem::path(__FILE__).parent_path() / "check_paths.yml";
ConfigNode node = load_file(check_path);
auto result = node["test"]["level1"].value();
ASSERT_EQ(result.get_config_path(), check_path);
}
TEST(PathConfigNodeWithPreset, NoPath) {
YAML::Node root = YAML::Load(R"(
a:
b:
c: 1
)");
ConfigNode tmp(root, std::nullopt, "root");
ConfigNodeWithPreset node(tmp);
auto a = node["a"].value();
auto b = a["b"].value();
auto c = b["c"].value();
ASSERT_EQ(b.get_config_path(), "root");
ASSERT_EQ(c.get_config_path(), "root");
}
TEST(PathConfigNodeWithPreset, PathExists) {
std::filesystem::path bus_topology_path =
std::filesystem::path(__FILE__).parent_path() / "check_paths.yml";
ConfigNodeWithPreset node = load_file_with_presets(bus_topology_path);
auto result = node["test"]["level1"].value();
ASSERT_EQ(result.get_config_path(), bus_topology_path);
}
TEST(PathConfigNode, IterateMap) {
std::filesystem::path check_path =
std::filesystem::path(__FILE__).parent_path() / "iterate_map.yml";
ConfigNode node = load_file(check_path);
auto map = node["map"].value();
for (auto it : map) {
ASSERT_EQ(it.get_config_path(), check_path);
}
}
TEST(PathConfigNode, IterateList) {
std::filesystem::path check_path =
std::filesystem::path(__FILE__).parent_path() / "iterate_list.yml";
ConfigNode node = load_file(check_path);
auto list = node["list"].value();
for (auto it : list) {
ASSERT_EQ(it.get_config_path(), check_path);
}
}
} // namespace test2
} // namespace sim