- Notifications
You must be signed in to change notification settings - Fork3
Path Schema Ordered updates#230
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
Show all changes
6 commits Select commitHold shift + click to select a range
244c6b6 Updated path.h schema
coder1376b89ef6 Updated path_schema.cpp
coder1372e1c41b Updated test_custom_generator
coder137db0abe6 Updated path schema ToPathString impl
coder137b9ef7ba Updated path ToPathString impl
coder13764fe59d Update test_path_schema.cpp
coder137File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
8 changes: 4 additions & 4 deletionsbuildcc/lib/target/include/target/custom_generator/custom_generator_context.h
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
2 changes: 1 addition & 1 deletionbuildcc/lib/target/test/target/test_custom_generator.cpp
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
8 changes: 8 additions & 0 deletionsbuildcc/schema/cmake/schema.cmake
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
78 changes: 48 additions & 30 deletionsbuildcc/schema/include/schema/path.h
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
132 changes: 132 additions & 0 deletionsbuildcc/schema/test/test_path_schema.cpp
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,132 @@ | ||
| // Internal | ||
| #include "schema/path.h" | ||
| #include "env/host_os.h" | ||
| // NOTE, Make sure all these includes are AFTER the system and header includes | ||
| #include "CppUTest/CommandLineTestRunner.h" | ||
| #include "CppUTest/MemoryLeakDetectorNewMacros.h" | ||
| #include "CppUTest/TestHarness.h" | ||
| #include "CppUTest/Utest.h" | ||
| // clang-format off | ||
| TEST_GROUP(PathSchemaTestGroup) | ||
| { | ||
| }; | ||
| // clang-format on | ||
| TEST(PathSchemaTestGroup, PathList) { buildcc::internal::PathList paths; } | ||
| TEST(PathSchemaTestGroup, Path_ToPathString) { | ||
| auto path_str = buildcc::internal::Path::ToPathString("hello/\\first.txt"); | ||
| if constexpr (buildcc::env::is_win()) { | ||
| STRCMP_EQUAL("hello\\first.txt", path_str.c_str()); | ||
| } else if constexpr (buildcc::env::is_linux() || buildcc::env::is_mac() || | ||
| buildcc::env::is_unix()) { | ||
| STRCMP_EQUAL("hello/\\first.txt", path_str.c_str()); | ||
| } else { | ||
| FAIL("Operating system not supported"); | ||
| } | ||
| } | ||
| TEST(PathSchemaTestGroup, PathInfoList_OrderedEmplace) { | ||
| buildcc::internal::PathInfoList path_infos; | ||
| path_infos.Emplace("hello/world/first_file.txt", ""); | ||
| path_infos.Emplace("hello/world/second_file.txt", ""); | ||
| path_infos.Emplace("hello/world/third_file.txt", ""); | ||
| path_infos.Emplace("hello/world/fourth_file.txt", ""); | ||
| std::vector<std::string> paths; | ||
| if constexpr (buildcc::env::is_win()) { | ||
| paths = { | ||
| "hello\\world\\first_file.txt", | ||
| "hello\\world\\second_file.txt", | ||
| "hello\\world\\third_file.txt", | ||
| "hello\\world\\fourth_file.txt", | ||
| }; | ||
| } else if constexpr (buildcc::env::is_linux() || buildcc::env::is_unix() || | ||
| buildcc::env::is_mac()) { | ||
| paths = { | ||
| "hello/world/first_file.txt", | ||
| "hello/world/second_file.txt", | ||
| "hello/world/third_file.txt", | ||
| "hello/world/fourth_file.txt", | ||
| }; | ||
| } else { | ||
| FAIL("Operating system not supported"); | ||
| } | ||
| auto inserted_paths = path_infos.GetPaths(); | ||
| for (std::size_t i = 0; i < inserted_paths.size(); i++) { | ||
| STRCMP_EQUAL(paths[i].c_str(), inserted_paths[i].c_str()); | ||
| } | ||
| json j = path_infos; | ||
| UT_PRINT(j.dump().c_str()); | ||
| } | ||
| TEST(PathSchemaTestGroup, PathInfoList_GetChanged) { | ||
| { | ||
| buildcc::internal::PathInfoList pinfolist1{ | ||
| {"first.txt", "1"}, | ||
| {"second.txt", "2"}, | ||
| {"third.txt", "3"}, | ||
| }; | ||
| buildcc::internal::PathInfoList pinfolist2{ | ||
| {"first.txt", "1"}, | ||
| {"second.txt", "2"}, | ||
| {"third.txt", "3"}, | ||
| }; | ||
| CHECK_TRUE(pinfolist1.IsEqual(pinfolist2)); | ||
| } | ||
| // Missing path info | ||
| { | ||
| buildcc::internal::PathInfoList pinfolist1{ | ||
| {"first.txt", "1"}, | ||
| {"second.txt", "2"}, | ||
| {"third.txt", "3"}, | ||
| }; | ||
| buildcc::internal::PathInfoList pinfolist2{ | ||
| {"first.txt", "1"}, {"second.txt", "2"}, | ||
| // {"third.txt", "3"}, | ||
| }; | ||
| CHECK_FALSE(pinfolist1.IsEqual(pinfolist2)); | ||
| } | ||
| // Wrong hash | ||
| { | ||
| buildcc::internal::PathInfoList pinfolist1{ | ||
| {"first.txt", "1"}, | ||
| {"second.txt", "2"}, | ||
| {"third.txt", "3"}, | ||
| }; | ||
| buildcc::internal::PathInfoList pinfolist2{ | ||
| {"first.txt", "1"}, | ||
| {"second.txt", "2"}, | ||
| {"third.txt", "4"}, | ||
| }; | ||
| CHECK_FALSE(pinfolist1.IsEqual(pinfolist2)); | ||
| } | ||
| // Wrong order | ||
| { | ||
| buildcc::internal::PathInfoList pinfolist1{ | ||
| {"first.txt", "1"}, | ||
| {"second.txt", "2"}, | ||
| {"third.txt", "3"}, | ||
| }; | ||
| buildcc::internal::PathInfoList pinfolist2{ | ||
| {"first.txt", "1"}, | ||
| {"third.txt", "3"}, | ||
| {"second.txt", "2"}, | ||
| }; | ||
| CHECK_FALSE(pinfolist1.IsEqual(pinfolist2)); | ||
| } | ||
| } | ||
| int main(int ac, char **av) { | ||
| return CommandLineTestRunner::RunAllTests(ac, av); | ||
| } |
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.