diff options
Diffstat (limited to 'graphics/asymptote/cxxtests')
6 files changed, 83 insertions, 0 deletions
diff --git a/graphics/asymptote/cxxtests/CMakeLists.txt b/graphics/asymptote/cxxtests/CMakeLists.txt new file mode 100644 index 0000000000..a8316cb134 --- /dev/null +++ b/graphics/asymptote/cxxtests/CMakeLists.txt @@ -0,0 +1,21 @@ +if (NOT ENABLE_ASY_CXXTEST) + message(FATAL_ERROR "cxxtests require asy-cxxtest enabled") +endif() + +set(TEST_CXX_SRC_ROOT ${CMAKE_CURRENT_LIST_DIR}) + +include(${TEST_CXX_SRC_ROOT}/cmake-scripts/external-libs.cmake) +include(${TEST_CXX_SRC_ROOT}/cmake-scripts/tests.cmake) + +# test target + +add_executable(asyCxxTests ${ASY_TEST_SOURCES} ${TEST_CXX_SRC_ROOT}/src/testMain.cc) +target_include_directories( + asyCxxTests + PRIVATE ${TEST_CXX_SRC_ROOT}/include +) +target_link_libraries(asyCxxTests + PRIVATE asycore GTest::gtest GTest::gmock) + +include(GoogleTest) +gtest_discover_tests(asyCxxTests TEST_PREFIX cxxtests.) diff --git a/graphics/asymptote/cxxtests/cmake-scripts/external-libs.cmake b/graphics/asymptote/cxxtests/cmake-scripts/external-libs.cmake new file mode 100644 index 0000000000..070d06a868 --- /dev/null +++ b/graphics/asymptote/cxxtests/cmake-scripts/external-libs.cmake @@ -0,0 +1,19 @@ +# Use directly downloaded library because vcpkg's version has some +# linking issues with windows + clang64-msys2 + +if (DOWNLOAD_GTEST_FROM_SRC) + include(FetchContent) + FetchContent_Declare( + googletest + GIT_REPOSITORY https://github.com/google/googletest + GIT_TAG v1.14.0 + ) + + if (WIN32) + set(gtest_force_shared_crt ON CACHE INTERNAL "Force shared CRT") + endif() + + FetchContent_MakeAvailable(googletest) +else() + find_package(GTest REQUIRED) +endif() diff --git a/graphics/asymptote/cxxtests/cmake-scripts/tests.cmake b/graphics/asymptote/cxxtests/cmake-scripts/tests.cmake new file mode 100644 index 0000000000..d76bcf7f3c --- /dev/null +++ b/graphics/asymptote/cxxtests/cmake-scripts/tests.cmake @@ -0,0 +1,12 @@ +# add tests here + +set(ASY_CXX_TESTS + placeholder +) + +# ----- transform tests -------- +list(TRANSFORM ASY_CXX_TESTS APPEND .cc) +list(TRANSFORM ASY_CXX_TESTS + PREPEND ${TEST_CXX_SRC_ROOT}/tests/ + OUTPUT_VARIABLE ASY_TEST_SOURCES +) diff --git a/graphics/asymptote/cxxtests/include/asycxxtests/common.h b/graphics/asymptote/cxxtests/include/asycxxtests/common.h new file mode 100644 index 0000000000..6a0640d082 --- /dev/null +++ b/graphics/asymptote/cxxtests/include/asycxxtests/common.h @@ -0,0 +1,9 @@ +/** + * @param asycxxtests/common.h + * @brief Common header file for all asymptote C++-side testing + */ + +#pragma once + +#include <gtest/gtest.h> +#include <gmock/gmock.h> diff --git a/graphics/asymptote/cxxtests/src/testMain.cc b/graphics/asymptote/cxxtests/src/testMain.cc new file mode 100644 index 0000000000..596daa3ce9 --- /dev/null +++ b/graphics/asymptote/cxxtests/src/testMain.cc @@ -0,0 +1,14 @@ +#include <gtest/gtest.h> +#include <gmock/gmock.h> +#include "common.h" + +int main(int argc, char* argv[]) +{ +#if defined(USEGC) + GC_init(); +#endif + + ::testing::InitGoogleTest(&argc,argv); + ::testing::InitGoogleMock(&argc,argv); + return RUN_ALL_TESTS(); +} diff --git a/graphics/asymptote/cxxtests/tests/placeholder.cc b/graphics/asymptote/cxxtests/tests/placeholder.cc new file mode 100644 index 0000000000..938775294b --- /dev/null +++ b/graphics/asymptote/cxxtests/tests/placeholder.cc @@ -0,0 +1,8 @@ +#include "asycxxtests/common.h" + +#define TESTING_FILE_NAME placeholder + +TEST(TESTING_FILE_NAME, alwaysTrue) +{ + ASSERT_TRUE(1==1); +} |