Skip to content

Commit

Permalink
Adding test script for two of the underlying functions.
Browse files Browse the repository at this point in the history
  • Loading branch information
yobeonline committed Mar 10, 2022
1 parent 3638e0c commit dae3835
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
38 changes: 38 additions & 0 deletions test_fetch_sources_and_groups.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
include(add_target.cmake)
include(unit_test_for_cmake/unit-test.cmake)

fetch_sources_and_groups("test.cpp" sources groups all)
EXPECT_EMPTY("${groups}")
EXPECT_EMPTY("${sources}")
EXPECT_STREQ("test.cpp" "${all}")

fetch_sources_and_groups("/.//;test.cpp" sources groups all)
EXPECT_EMPTY("${groups}")
EXPECT_EMPTY("${sources}")
EXPECT_STREQ("test.cpp" "${all}")

fetch_sources_and_groups("/sources//;test.cpp" sources groups all)
EXPECT_STREQ("sources" "${groups}")
EXPECT_STREQ("test.cpp" "${sources}")
EXPECT_STREQ("test.cpp" "${all}")

fetch_sources_and_groups("test.h;/sources//;test.cpp" sources groups all)
EXPECT_STREQ("sources" "${groups}")
EXPECT_STREQ("test.cpp" "${sources}")
EXPECT_STREQ("test.h;test.cpp" ${all})

fetch_sources_and_groups("test.h;/sources//;test.cpp;details//;impl.cpp" sources groups all)
EXPECT_STREQ("sources;sources/details" "${groups}")
EXPECT_STREQ("test.cpp;impl.cpp" "${sources}")
EXPECT_STREQ("test.h;test.cpp;impl.cpp" "${all}")

fetch_sources_and_groups("test.h;/sources//;test.cpp;/details//;impl.cpp" sources groups all)
EXPECT_STREQ("sources;details" "${groups}")
EXPECT_STREQ("test.cpp;impl.cpp" "${sources}")
EXPECT_STREQ("test.h;test.cpp;impl.cpp" "${all}")

fetch_sources_and_groups("test.h;/sources//;test.cpp;../details//;impl.cpp" sources groups all)
EXPECT_STREQ("sources;details" "${groups}")
EXPECT_STREQ("test.cpp;impl.cpp" "${sources}")
EXPECT_STREQ("test.h;test.cpp;impl.cpp" "${all}")

18 changes: 18 additions & 0 deletions test_parse_file_options.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
include(add_target.cmake)
include(unit_test_for_cmake/unit-test.cmake)

parse_file_options("test.cpp" file options)
EXPECT_STREQ("${file}" "test.cpp")
EXPECT_EMPTY("${options}")

parse_file_options("test.cpp:toto" file options)
EXPECT_STREQ("${file}" "test.cpp")
EXPECT_STREQ("${options}" "toto")

parse_file_options("test.cpp:toto,tata" file options)
EXPECT_STREQ("${file}" "test.cpp")
EXPECT_STREQ("${options}" "toto;tata")

parse_file_options("test.cpp" file options)
EXPECT_STREQ("${file}" "test.cpp")
EXPECT_EMPTY("${options}")

0 comments on commit dae3835

Please sign in to comment.