diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 79ff527..c236c45 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -9,5 +9,17 @@ include(doctest) add_executable(lbstd_version_tests test.cpp) target_link_libraries(lbstd_version_tests doctest::doctest lbstd_version) +add_executable(lbstd_version_print_ns print_ns.cpp) +target_link_libraries(lbstd_version_print_ns lbstd_version) + +# The manual test for namespace passthrough. +set(LBSTD_VERSION_CMAKE_NS_PASSTHROUGH "CMake custom library namespace (\"${LBSTD_VERSION_NS}::\") passthrough in C++ code") +add_test(NAME "${LBSTD_VERSION_CMAKE_NS_PASSTHROUGH}" COMMAND lbstd_version_print_ns) +set_tests_properties("${LBSTD_VERSION_CMAKE_NS_PASSTHROUGH}" PROPERTIES + PASS_REGULAR_EXPRESSION "${LBSTD_VERSION_NS}" + LABELS "buildsystem" +) + +# Auto-discoverable doctest unit tests doctest_discover_tests(lbstd_version_tests ADD_LABELS ON) diff --git a/tests/print_ns.cpp b/tests/print_ns.cpp new file mode 100644 index 0000000..c2ffe3a --- /dev/null +++ b/tests/print_ns.cpp @@ -0,0 +1,20 @@ +// SPDX-FileCopyrightText: 2022 leha-bot and contributors +// +// SPDX-License-Identifier: BSL-1.0 OR BlueOak-1.0.0 +// +// This executable is a smoke test for checking the proper namespace customizing via CMake's +// -DLBSTD_VERSION_NS="namespace_name" configure parameter. The main() function just prints the +// actual namespace which will be used in CMake's test check. +#include + +#include + +#define MAKE_STRING(q) #q +#define UNPACK_MACRO(q) q +#define MAKE_STRING_FROM_MACRO(q) MAKE_STRING(q) + +int main() +{ + std::cout << MAKE_STRING_FROM_MACRO(LB_STD_VERSION_NS); + return 0; +}