diff --git a/Testing/TableTest.h b/Testing/TableTest.h index 483b6a1..abb125b 100644 --- a/Testing/TableTest.h +++ b/Testing/TableTest.h @@ -8,6 +8,9 @@ static_assert( __cplusplus > 201700, "C++17 Required" ); #include #include #include +#include + +#include #include #include @@ -25,6 +28,15 @@ namespace Alepha::Hydrogen::Testing template< auto > struct TableTest; } + inline void breakpoint() {} + + namespace C + { + const bool debug= false; + const bool debugCaseTypes= false or C::debug; + using namespace Alepha::exports::console::C; + } + using namespace Utility::exports::evaluation; template< typename RetVal, typename ... Args, RetVal (*function)( Args... ) > @@ -48,6 +60,8 @@ namespace Alepha::Hydrogen::Testing int failureCount= 0; for( const auto &[ comment, params, expected ]: tests ) { + if( C::debugCaseTypes ) std::cerr << boost::core::demangle( typeid( params ).name() ) << std::endl; + breakpoint(); if( std::apply( function, params ) != expected ) { std::cout << C::red << " FAILURE" << C::normal << ": " << comment << std::endl; @@ -60,9 +74,10 @@ namespace Alepha::Hydrogen::Testing } }; - struct VectorCases; + //struct VectorCases; }; +#ifdef DISABLED template< typename RetVal, typename ... Args, RetVal (*function)( Args... ) > struct TableTest< function >::VectorCases { @@ -112,6 +127,7 @@ namespace Alepha::Hydrogen::Testing return failureCount; } }; +#endif } namespace exports::table_test diff --git a/Testing/test.h b/Testing/test.h index bbcbfe2..e0654e9 100644 --- a/Testing/test.h +++ b/Testing/test.h @@ -14,6 +14,7 @@ static_assert( __cplusplus > 201700, "C++17 Required" ); #include #include +#include namespace Alepha::Hydrogen::Testing { @@ -200,7 +201,7 @@ namespace Alepha::Hydrogen::Testing } [[nodiscard]] inline int - runAllTests( const unsigned argcnt, const char *const *const argvec ) + runAllTests( const argcnt_t argcnt, const argvec_t argvec ) { return runAllTests( { argvec + 1, argvec + argcnt } ); } diff --git a/Testing/test2.cc b/Testing/test2.cc new file mode 100644 index 0000000..b9311b8 --- /dev/null +++ b/Testing/test2.cc @@ -0,0 +1,45 @@ +static_assert( __cplusplus > 201700, "C++17 Required" ); + +#include +#include +#include + + +int +main( const int argcnt, const char *const *const argvec ) +{ + return Alepha::Testing::runAllTests( argcnt, argvec ); +} + + +namespace +{ + using namespace Alepha::Testing::exports; + using namespace Alepha::Utility::exports::evaluation; + + int + add( int a, int b ) + { + return a + b; + } + + auto basic_test= "basic_test"_test <=[] + { + return 0; + }; + + auto test= "addition.two.test"_test <=TableTest< add >::Cases + { + { "Basic Smoke Test", { 2, 2 }, 4 }, + { "Lefthand identity", { 0, 25 }, 25 }, + { "Righthand identity", { 25, 0 }, 25 }, + }; + + auto alltests= enroll <=[] + { + "addition.two.local"_test <=TableTest< add >::Cases + { + { "Negative case", { -10, -20 }, -30 }, + }; + }; +} diff --git a/console.h b/console.h index e7e6a09..6d76a4a 100644 --- a/console.h +++ b/console.h @@ -17,9 +17,65 @@ namespace Alepha::Hydrogen namespace C { const std::string csi= "\e["; - const std::string green= C::csi + "32m"; - const std::string red= C::csi + "31m"; - const std::string normal= C::csi + "0m"; + const std::string color_code= "m"; + + enum Layer + { + fg_code= '3', + bg_code= '4', + }; + + enum class Color : char + { + black= '0', + red= '1', + green= '2', + brown= '3', + blue= '4', + magenta= '5', + cyan= '6', + white= '7', + }; + } + using C::Layer; + using C::Color; + + inline std::string + make_color( const Layer layer, const Color color ) + { + return C::csi + char(layer) + char(color) + C::color_code; + } + + namespace C + { + inline namespace exports + { + const std::string normal= C::csi + '0' + color_code; + + inline namespace fg + { + const std::string black= make_color( C::fg_code, C::Color::black ); + const std::string red= make_color( C::fg_code, C::Color::red ); + const std::string green= make_color( C::fg_code, C::Color::green ); + const std::string brown= make_color( C::fg_code, C::Color::brown ); + const std::string blue= make_color( C::fg_code, C::Color::blue ); + const std::string magenta= make_color( C::fg_code, C::Color::magenta ); + const std::string cyan= make_color( C::fg_code, C::Color::cyan ); + const std::string white= make_color( C::fg_code, C::Color::white ); + } + + namespace bg + { + const std::string black= make_color( C::bg_code, C::Color::black ); + const std::string red= make_color( C::bg_code, C::Color::red ); + const std::string green= make_color( C::bg_code, C::Color::green ); + const std::string brown= make_color( C::bg_code, C::Color::brown ); + const std::string blue= make_color( C::bg_code, C::Color::blue ); + const std::string magenta= make_color( C::bg_code, C::Color::magenta ); + const std::string cyan= make_color( C::bg_code, C::Color::cyan ); + const std::string white= make_color( C::bg_code, C::Color::white ); + } + } } namespace exports