1- #pragma once
2-
31#include < gtest/gtest.h>
42
53#include " parser/config_reader/config_node_with_preset.hpp"
@@ -16,9 +14,9 @@ TEST(PathConfigNode, InsertedPath){
1614)" );
1715 ConfigNode node (root, std::nullopt , " root" );
1816 auto a = node[" a" ].value ();
19- auto b = node [" b" ].value ();
20- auto c = node [" c" ].value ();
21- ASSERT_EQ (a. get_path_node (), " root \\ a " );
17+ auto b = a [" b" ].value ();
18+ auto c = b [" c" ].value ();
19+
2220 ASSERT_EQ (b.get_path_node (), " root\\ a\\ b" );
2321 ASSERT_EQ (c.get_path_node (), " root\\ a\\ b\\ c" );
2422}
@@ -27,9 +25,36 @@ TEST(PathConfigNode, MissingKey){
2725 std::filesystem::path bus_topology_path =
2826 std::filesystem::path (__FILE__).parent_path () /
2927 " bus_network.yml" ;
30- ConfigNode node = load_file (path);
31- auto result = node[" connection-1->1" ].value ();
32- ASSERT_EQ (result.get_path_node (), bus_topology_path.string () + " connections\\ connection-1->1" );
28+ ConfigNode node = load_file (bus_topology_path);
29+ auto result = node[" connections" ][" connection-1->1" ].value ();
30+
31+ ASSERT_EQ (result.get_path_node (), bus_topology_path.string () + " \\ connections\\ connection-1->1" );
32+ }
33+
34+ TEST (PathConfigNodeWithPreset, InsertedPath){
35+ YAML ::Node root = YAML::Load (R"(
36+ a:
37+ b:
38+ c: 1
39+ )" );
40+ ConfigNode tmp (root, std::nullopt , " root" );
41+ ConfigNodeWithPreset node (tmp);
42+ auto a = node[" a" ].value ();
43+ auto b = a[" b" ].value ();
44+ auto c = b[" c" ].value ();
45+
46+ ASSERT_EQ (b.get_path_node (), " root\\ a\\ b" );
47+ ASSERT_EQ (c.get_path_node (), " root\\ a\\ b\\ c" );
48+ }
49+
50+ TEST (PathConfigNodeWithPreset, MissingKey){
51+ std::filesystem::path bus_topology_path =
52+ std::filesystem::path (__FILE__).parent_path () /
53+ " bus_network.yml" ;
54+ ConfigNodeWithPreset node = load_file_with_presets (bus_topology_path);
55+ auto result = node[" connections" ][" connection-1->1" ].value ();
56+
57+ ASSERT_EQ (result.get_path_node (), bus_topology_path.string () + " \\ connections\\ connection-1->1" );
3358}
3459
3560}
0 commit comments