diff options
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/CMakeLib/CMakeLists.txt | 1 | ||||
-rw-r--r-- | Tests/CMakeLib/testCMExtAlgorithm.cxx | 117 | ||||
-rw-r--r-- | Tests/CMakeLib/testCTestResourceSpec.cxx | 73 | ||||
-rw-r--r-- | Tests/CustomCommand/CMakeLists.txt | 15 | ||||
-rw-r--r-- | Tests/QtAutogen/SameName/CMakeLists.txt | 1 | ||||
-rw-r--r-- | Tests/QtAutogen/SameName/main.cpp | 2 | ||||
-rw-r--r-- | Tests/QtAutogen/SameName/object.hh | 13 |
7 files changed, 169 insertions, 53 deletions
diff --git a/Tests/CMakeLib/CMakeLists.txt b/Tests/CMakeLib/CMakeLists.txt index 976c924..25d2de6 100644 --- a/Tests/CMakeLib/CMakeLists.txt +++ b/Tests/CMakeLib/CMakeLists.txt @@ -26,6 +26,7 @@ set(CMakeLib_TESTS testUVRAII.cxx testUVStreambuf.cxx testCMExtMemory.cxx + testCMExtAlgorithm.cxx ) add_executable(testUVProcessChainHelper testUVProcessChainHelper.cxx) diff --git a/Tests/CMakeLib/testCMExtAlgorithm.cxx b/Tests/CMakeLib/testCMExtAlgorithm.cxx new file mode 100644 index 0000000..c731b72 --- /dev/null +++ b/Tests/CMakeLib/testCMExtAlgorithm.cxx @@ -0,0 +1,117 @@ +#include <iostream> +#include <memory> +#include <utility> +#include <vector> + +#include <cmext/algorithm> + +namespace { + +int failed = 0; + +void testAppend() +{ + std::cout << "testAppend()" << std::endl; + + // ---------------------------------------------------- + // cm::append(Vector, Iterator, Iterator) + { + std::vector<int> v1{ 1, 2, 3 }; + std::vector<int> v1_ref{ 1, 2, 3, 4, 5, 6 }; + std::vector<int> v2{ 4, 5, 6 }; + std::vector<int> v2_ref{ 4, 5, 6 }; + + cm::append(v1, v2.begin(), v2.end()); + + if (v1 != v1_ref || v2 != v2_ref) { + ++failed; + } + } + + // ---------------------------------------------------- + // cm::append(Vector, Range) + { + std::vector<int> v1{ 1, 2, 3 }; + std::vector<int> v1_ref{ 1, 2, 3, 4, 5, 6 }; + std::vector<int> v2{ 4, 5, 6 }; + std::vector<int> v2_ref{ 4, 5, 6 }; + + cm::append(v1, v2); + + if (v1 != v1_ref || v2 != v2_ref) { + ++failed; + } + } + + // ---------------------------------------------------- + // cm::append(Vector<*>, Vector<unique_ptr>) + { + std::vector<int*> v1{ new int(1), new int(2), new int(3) }; + std::vector<int*> v1_ref = v1; + std::vector<std::unique_ptr<int>> v2; + + v2.emplace_back(new int(4)); + v2.emplace_back(new int(5)); + v2.emplace_back(new int(6)); + + cm::append(v1, v2); + + if (v1.size() == 6 && v2.size() == 3) { + for (int i = 0; i < 3; i++) { + if (v1[i] != v1_ref[i]) { + ++failed; + break; + } + } + for (int i = 0; i < 3; i++) { + if (v1[i + 3] != v2[i].get()) { + ++failed; + break; + } + } + } else { + ++failed; + } + + // free memory to please memory sanitizer + delete v1[0]; + delete v1[1]; + delete v1[2]; + } + + // ---------------------------------------------------- + // cm::append(Vector<unique_ptr>, Vector<unique_ptr>) + { + std::vector<std::unique_ptr<int>> v1; + std::vector<std::unique_ptr<int>> v2; + + v1.emplace_back(new int(1)); + v1.emplace_back(new int(2)); + v1.emplace_back(new int(3)); + + v2.emplace_back(new int(4)); + v2.emplace_back(new int(5)); + v2.emplace_back(new int(6)); + + cm::append(v1, std::move(v2)); + + if (v1.size() == 6 && v2.empty()) { + for (int i = 0; i < 6; i++) { + if (*v1[i] != i + 1) { + ++failed; + break; + } + } + } else { + ++failed; + } + } +} +} + +int testCMExtAlgorithm(int /*unused*/, char* /*unused*/ []) +{ + testAppend(); + + return failed; +} diff --git a/Tests/CMakeLib/testCTestResourceSpec.cxx b/Tests/CMakeLib/testCTestResourceSpec.cxx index b69003d..99bee56 100644 --- a/Tests/CMakeLib/testCTestResourceSpec.cxx +++ b/Tests/CMakeLib/testCTestResourceSpec.cxx @@ -21,43 +21,42 @@ static const std::vector<ExpectedSpec> expectedResourceSpecs = { {"threads", { }}, }}}}, - {"spec2.json", true, {{{ - }}}}, - {"spec3.json", false, {{{}}}}, - {"spec4.json", false, {{{}}}}, - {"spec5.json", false, {{{}}}}, - {"spec6.json", false, {{{}}}}, - {"spec7.json", false, {{{}}}}, - {"spec8.json", false, {{{}}}}, - {"spec9.json", false, {{{}}}}, - {"spec10.json", false, {{{}}}}, - {"spec11.json", false, {{{}}}}, - {"spec12.json", false, {{{}}}}, - {"spec13.json", false, {{{}}}}, - {"spec14.json", true, {{{}}}}, - {"spec15.json", true, {{{}}}}, - {"spec16.json", true, {{{}}}}, - {"spec17.json", false, {{{}}}}, - {"spec18.json", false, {{{}}}}, - {"spec19.json", false, {{{}}}}, - {"spec20.json", true, {{{}}}}, - {"spec21.json", false, {{{}}}}, - {"spec22.json", false, {{{}}}}, - {"spec23.json", false, {{{}}}}, - {"spec24.json", false, {{{}}}}, - {"spec25.json", false, {{{}}}}, - {"spec26.json", false, {{{}}}}, - {"spec27.json", false, {{{}}}}, - {"spec28.json", false, {{{}}}}, - {"spec29.json", false, {{{}}}}, - {"spec30.json", false, {{{}}}}, - {"spec31.json", false, {{{}}}}, - {"spec32.json", false, {{{}}}}, - {"spec33.json", false, {{{}}}}, - {"spec34.json", false, {{{}}}}, - {"spec35.json", false, {{{}}}}, - {"spec36.json", false, {{{}}}}, - {"noexist.json", false, {{{}}}}, + {"spec2.json", true, {}}, + {"spec3.json", false, {}}, + {"spec4.json", false, {}}, + {"spec5.json", false, {}}, + {"spec6.json", false, {}}, + {"spec7.json", false, {}}, + {"spec8.json", false, {}}, + {"spec9.json", false, {}}, + {"spec10.json", false, {}}, + {"spec11.json", false, {}}, + {"spec12.json", false, {}}, + {"spec13.json", false, {}}, + {"spec14.json", true, {}}, + {"spec15.json", true, {}}, + {"spec16.json", true, {}}, + {"spec17.json", false, {}}, + {"spec18.json", false, {}}, + {"spec19.json", false, {}}, + {"spec20.json", true, {}}, + {"spec21.json", false, {}}, + {"spec22.json", false, {}}, + {"spec23.json", false, {}}, + {"spec24.json", false, {}}, + {"spec25.json", false, {}}, + {"spec26.json", false, {}}, + {"spec27.json", false, {}}, + {"spec28.json", false, {}}, + {"spec29.json", false, {}}, + {"spec30.json", false, {}}, + {"spec31.json", false, {}}, + {"spec32.json", false, {}}, + {"spec33.json", false, {}}, + {"spec34.json", false, {}}, + {"spec35.json", false, {}}, + {"spec36.json", false, {}}, + {"noexist.json", false, {}}, /* clang-format on */ }; diff --git a/Tests/CustomCommand/CMakeLists.txt b/Tests/CustomCommand/CMakeLists.txt index e4b50d0..70e8476 100644 --- a/Tests/CustomCommand/CMakeLists.txt +++ b/Tests/CustomCommand/CMakeLists.txt @@ -534,3 +534,18 @@ add_custom_command( set_property(SOURCE "${gen_file}" PROPERTY SYMBOLIC ON) add_custom_target(command_expand_lists ALL DEPENDS "${gen_file}") set_property(TARGET command_expand_lists PROPERTY CMPARGS "${cmp_args}") + +set(depends_path "./depended_upon_path.txt") + +add_custom_command( + OUTPUT ${depends_path} + COMMAND ${CMAKE_COMMAND} -E touch ${depends_path} +) + +add_custom_command( + OUTPUT "depends_on_path.txt" + COMMAND ${CMAKE_COMMAND} -E touch "depends_on_path.txt" + DEPENDS ${depends_path} +) + +add_custom_target(depends_on_path ALL DEPENDS "depends_on_path.txt") diff --git a/Tests/QtAutogen/SameName/CMakeLists.txt b/Tests/QtAutogen/SameName/CMakeLists.txt index 1919cc7..cd29a2a 100644 --- a/Tests/QtAutogen/SameName/CMakeLists.txt +++ b/Tests/QtAutogen/SameName/CMakeLists.txt @@ -18,7 +18,6 @@ add_executable(sameName ccc/data.qrc item.cpp object.h - object.hh object.h++ object.hpp object.hxx diff --git a/Tests/QtAutogen/SameName/main.cpp b/Tests/QtAutogen/SameName/main.cpp index 725f4cd..19a6f6d 100644 --- a/Tests/QtAutogen/SameName/main.cpp +++ b/Tests/QtAutogen/SameName/main.cpp @@ -6,7 +6,6 @@ #include "item.hpp" #include "object.h" #include "object.h++" -#include "object.hh" #include "object.hpp" #include "object.hxx" #include "object_upper_ext.H" @@ -22,7 +21,6 @@ int main(int argv, char** args) ::ccc::Item ccc_item; // Object instances ::Object_h obj_h; - ::Object_hh obj_hh; ::Object_hplpl obj_hplpl; ::Object_hpp obj_hpp; ::Object_hxx obj_hxx; diff --git a/Tests/QtAutogen/SameName/object.hh b/Tests/QtAutogen/SameName/object.hh deleted file mode 100644 index 3e16f83..0000000 --- a/Tests/QtAutogen/SameName/object.hh +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef OBJECT_HH -#define OBJECT_HH - -#include <QObject> - -class Object_hh : public QObject -{ - Q_OBJECT - Q_SLOT - void go(){}; -}; - -#endif |