-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcheck_paths.cpp
More file actions
61 lines (50 loc) · 1.71 KB
/
Copy pathcheck_paths.cpp
File metadata and controls
61 lines (50 loc) · 1.71 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
#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, InsertedPath) {
YAML::Node root = YAML::Load(R"(
a:
b:
c: 1
)");
ConfigNode node(root, std::nullopt, "root");
auto a = node["a"].value();
auto b = a["b"].value();
auto c = b["c"].value();
ASSERT_EQ(b.get_path_node(), "root\\a\\b");
ASSERT_EQ(c.get_path_node(), "root\\a\\b\\c");
}
TEST(PathConfigNode, MissingKey) {
std::filesystem::path bus_topology_path =
std::filesystem::path(__FILE__).parent_path() / "bus_network.yml";
ConfigNode node = load_file(bus_topology_path);
auto result = node["connections"]["connection-1->1"].value();
ASSERT_EQ(result.get_path_node(),
bus_topology_path.string() + "\\connections\\connection-1->1");
}
TEST(PathConfigNodeWithPreset, InsertedPath) {
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_path_node(), "root\\a\\b");
ASSERT_EQ(c.get_path_node(), "root\\a\\b\\c");
}
TEST(PathConfigNodeWithPreset, MissingKey) {
std::filesystem::path bus_topology_path =
std::filesystem::path(__FILE__).parent_path() / "bus_network.yml";
ConfigNodeWithPreset node = load_file_with_presets(bus_topology_path);
auto result = node["connections"]["connection-1->1"].value();
ASSERT_EQ(result.get_path_node(),
bus_topology_path.string() + "\\connections\\connection-1->1");
}
} // namespace test2
} // namespace sim