From a8433d13e3531e11a124f9f78ca83d9006e3de88 Mon Sep 17 00:00:00 2001 From: ADAM David Alan Martin Date: Thu, 12 Oct 2023 18:57:40 -0400 Subject: [PATCH] More progress on the testing front. --- CMakeLists.txt | 1 + Testing/CMakeLists.txt | 2 ++ Testing/TableTest.h | 2 +- Testing/test.h | 7 ++++++- Testing/testlib.cc | 25 +++++++++++++++++++++++++ word_wrap.test/0.cc | 21 +++++++++++++++++++++ word_wrap.test/CMakeLists.txt | 2 ++ 7 files changed, 58 insertions(+), 2 deletions(-) create mode 100644 Testing/testlib.cc create mode 100644 word_wrap.test/0.cc create mode 100644 word_wrap.test/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 24be548..d6c8d28 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,6 +26,7 @@ add_subdirectory( Testing ) add_subdirectory( AutoRAII.test ) add_subdirectory( comparisons.test ) add_subdirectory( Exception.test ) +add_subdirectory( word_wrap.test ) # Sample applications add_executable( example example.cc ) diff --git a/Testing/CMakeLists.txt b/Testing/CMakeLists.txt index 3d2bf00..4a30b10 100644 --- a/Testing/CMakeLists.txt +++ b/Testing/CMakeLists.txt @@ -1 +1,3 @@ add_subdirectory( TableTest.test ) + +add_library( unit-test SHARED testlib.cc ) diff --git a/Testing/TableTest.h b/Testing/TableTest.h index 2b556cd..84212a9 100644 --- a/Testing/TableTest.h +++ b/Testing/TableTest.h @@ -34,7 +34,7 @@ namespace Alepha::Hydrogen::Testing { const bool debug= false; const bool debugCaseTypes= false or C::debug; - using namespace Alepha::exports::console::C; + using namespace Alepha::console::C; } using namespace Utility::exports::evaluation; diff --git a/Testing/test.h b/Testing/test.h index ccbc83b..fe72aad 100644 --- a/Testing/test.h +++ b/Testing/test.h @@ -32,7 +32,7 @@ namespace Alepha::Hydrogen::Testing const bool debugTestRegistration= false or C::debug; const bool debugTestRun= false or C::debug; - using namespace Alepha::exports::C; + using namespace Alepha::Hydrogen::exports::C; } using namespace std::literals::string_literals; @@ -227,4 +227,9 @@ namespace Alepha::Hydrogen::Testing { using namespace detail::testing::exports; } + + namespace exports::inline literals::inline program_option_literals + { + using namespace detail::testing::exports::literals; + } } diff --git a/Testing/testlib.cc b/Testing/testlib.cc new file mode 100644 index 0000000..b3d989c --- /dev/null +++ b/Testing/testlib.cc @@ -0,0 +1,25 @@ +static_assert( __cplusplus > 2020'00 ); + +#include +#include + +namespace +{ + namespace impl + { + int + main( const int argcnt, const char *const *const argvec ) + { + // TODO: Have test selection options here and more. + const auto args= Alepha::handleOptions( argcnt, argvec ); + const auto result= Alepha::Testing::runAllTests( args ); + return result; + } + } +} + +int +main( const int argcnt, const char *const *const argvec ) +{ + return impl::main( argcnt, argvec ); +} diff --git a/word_wrap.test/0.cc b/word_wrap.test/0.cc new file mode 100644 index 0000000..00d4518 --- /dev/null +++ b/word_wrap.test/0.cc @@ -0,0 +1,21 @@ +static_assert( __cplusplus > 2020'00 ); + +#include "../word_wrap.h" + +#include +#include +#include + +namespace +{ + using namespace Alepha::Testing::literals::program_option_literals; + using Alepha::Testing::TableTest; +} + +static auto init= Alepha::Utility::enroll <=[] +{ + "Does word wrap with no-indent do sensible things?"_test <=TableTest< Alepha::wordWrap >::Cases + { + { "Three word with break after first?", { "Goodbye cruel world!", 12, 0 }, "Goodbye \ncruel world!" }, + }; +}; diff --git a/word_wrap.test/CMakeLists.txt b/word_wrap.test/CMakeLists.txt new file mode 100644 index 0000000..d31c4a6 --- /dev/null +++ b/word_wrap.test/CMakeLists.txt @@ -0,0 +1,2 @@ +link_libraries( unit-test ) +unit_test( 0 )