-
Notifications
You must be signed in to change notification settings - Fork 1
FEAT: add path to ConfigNode
#547
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 3 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
1743b0b
doesn't work. need to check
59e3c5c
done
bca59d0
formatted
622355e
resolved conversation
f2ea0e9
formatted
a51e960
change path to std::filesystem::path
d8431d6
formatted
74f985f
fix conversations
d56d4eb
formatted
8ea6318
fix
af6b033
done
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| #include <gtest/gtest.h> | ||
|
S1mpotyaga marked this conversation as resolved.
Outdated
|
||
|
|
||
| #include "parser/config_reader/config_node.hpp" | ||
| #include "parser/config_reader/config_node_with_preset.hpp" | ||
|
|
||
| namespace sim { | ||
| namespace test2 { | ||
|
|
||
| TEST(PathConfigNode, InsertedPath) { | ||
|
S1mpotyaga marked this conversation as resolved.
Outdated
S1mpotyaga marked this conversation as resolved.
Outdated
|
||
| 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) { | ||
|
S1mpotyaga marked this conversation as resolved.
Outdated
|
||
| std::filesystem::path bus_topology_path = | ||
|
S1mpotyaga marked this conversation as resolved.
Outdated
|
||
| 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) { | ||
|
S1mpotyaga marked this conversation as resolved.
Outdated
|
||
| 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) { | ||
|
S1mpotyaga marked this conversation as resolved.
Outdated
|
||
| 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 | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.