forked from Alepha/Alepha
Update and consolidate the console and colors code.
This introduces a subset of SGR-Name syntax.
This commit is contained in:
@ -32,7 +32,9 @@ static_assert( __cplusplus > 2020'00 );
|
||||
#include <Alepha/Utility/evaluation_helpers.h>
|
||||
|
||||
#include <Alepha/TotalOrder.h>
|
||||
#include <Alepha/console.h>
|
||||
#include <Alepha/Console.h>
|
||||
|
||||
#include "colors.h"
|
||||
|
||||
namespace Alepha::Hydrogen::Testing ::detail:: table_test
|
||||
{
|
||||
@ -41,6 +43,14 @@ namespace Alepha::Hydrogen::Testing ::detail:: table_test
|
||||
enum class OutputMode { All, Relaxed };
|
||||
}
|
||||
|
||||
namespace C
|
||||
{
|
||||
inline namespace Colors
|
||||
{
|
||||
using namespace testing_colors::C::Colors;
|
||||
}
|
||||
}
|
||||
|
||||
template< typename F >
|
||||
concept FunctionVariable=
|
||||
requires( const F &f )
|
||||
@ -60,7 +70,6 @@ namespace Alepha::Hydrogen::Testing ::detail:: table_test
|
||||
{
|
||||
const bool debug= false;
|
||||
const bool debugCaseTypes= false or C::debug;
|
||||
using namespace Alepha::console::C;
|
||||
}
|
||||
|
||||
using std::begin, std::end;
|
||||
@ -260,11 +269,11 @@ namespace Alepha::Hydrogen::Testing ::detail:: table_test
|
||||
const auto result= witness == expected;
|
||||
if( not result )
|
||||
{
|
||||
std::cout << C::red << " FAILURE" << C::normal << ": " << comment << std::endl;
|
||||
std::cout << C::testFail << " FAILURE" << resetStyle << ": " << comment << std::endl;
|
||||
++failureCount;
|
||||
printDebugging< outputMode >( witness, expected );
|
||||
}
|
||||
else std::cout << C::green << " SUCCESS" << C::normal << ": " << comment << std::endl;
|
||||
else std::cout << C::testPass << " SUCCESS" << resetStyle << ": " << comment << std::endl;
|
||||
}
|
||||
|
||||
return failureCount;
|
||||
|
17
Testing/colors.h
Normal file
17
Testing/colors.h
Normal file
@ -0,0 +1,17 @@
|
||||
static_assert( __cplusplus > 2020'00 );
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Alepha/Console.h>
|
||||
|
||||
namespace Alepha::Hydrogen::Testing ::detail:: testing_colors
|
||||
{
|
||||
namespace C
|
||||
{
|
||||
inline namespace Colors
|
||||
{
|
||||
inline const auto testFail= createStyle( "test-failure", setFgColor( BasicTextColor::red ) );
|
||||
inline const auto testPass= createStyle( "test-success", setFgColor( BasicTextColor::green ) );
|
||||
}
|
||||
}
|
||||
}
|
@ -13,12 +13,14 @@ static_assert( __cplusplus > 2020'00 );
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
|
||||
#include <Alepha/console.h>
|
||||
#include <Alepha/Console.h>
|
||||
#include <Alepha/types.h>
|
||||
|
||||
#include <Alepha/Utility/evaluation_helpers.h>
|
||||
#include <Alepha/Utility/StaticValue.h>
|
||||
|
||||
#include "colors.h"
|
||||
|
||||
namespace Alepha::Hydrogen::Testing
|
||||
{
|
||||
inline namespace exports { inline namespace testing {} }
|
||||
@ -33,7 +35,7 @@ namespace Alepha::Hydrogen::Testing
|
||||
const bool debugTestRegistration= false or C::debug;
|
||||
const bool debugTestRun= false or C::debug;
|
||||
|
||||
using namespace Alepha::Hydrogen::exports::C;
|
||||
using namespace testing_colors::C::Colors;
|
||||
}
|
||||
|
||||
using namespace std::literals::string_literals;
|
||||
@ -196,9 +198,9 @@ namespace Alepha::Hydrogen::Testing
|
||||
|
||||
if( explicitlyNamed( name ) or not disabled and selected( name ) )
|
||||
{
|
||||
std::cout << C::green << "BEGIN " << C::normal << ": " << name << std::endl;
|
||||
std::cout << C::testPass << "BEGIN " << resetStyle << ": " << name << std::endl;
|
||||
test();
|
||||
std::cout << C::green << "SUCCESS" << C::normal << ": " << name << std::endl;
|
||||
std::cout << C::testPass << "SUCCESS" << resetStyle << ": " << name << std::endl;
|
||||
}
|
||||
}
|
||||
catch( ... )
|
||||
@ -206,7 +208,7 @@ namespace Alepha::Hydrogen::Testing
|
||||
try
|
||||
{
|
||||
failed= true;
|
||||
std::cout << C::red << "FAILURE" << C::normal << ": " << name;
|
||||
std::cout << C::testFail << "FAILURE" << resetStyle << ": " << name;
|
||||
throw;
|
||||
}
|
||||
catch( const TestFailureException &fail ) { std::cout << " -- " << fail.failureCount << " failures."; }
|
||||
|
Reference in New Issue
Block a user