1
0
forked from Alepha/Alepha

Add tests for string algorithms.

This commit is contained in:
2023-10-15 19:51:37 -04:00
parent f1f010fdb2
commit f0b514dccd
3 changed files with 49 additions and 0 deletions

View File

@ -27,6 +27,7 @@ add_subdirectory( AutoRAII.test )
add_subdirectory( comparisons.test )
add_subdirectory( Exception.test )
add_subdirectory( word_wrap.test )
add_subdirectory( string_algorithms.test )
# Sample applications
add_executable( example example.cc )

View File

@ -0,0 +1,45 @@
static_assert( __cplusplus > 2020'00 );
#include "../string_algorithms.h"
#include <Alepha/Testing/test.h>
#include <Alepha/Testing/TableTest.h>
#include <Alepha/Utility/evaluation.h>
namespace
{
using namespace Alepha::Testing::literals::test_literals;
using namespace Alepha::Testing::exports;
using Alepha::Utility::exports::enroll;
using Alepha::Utility::exports::lambaste;
}
static auto init= enroll <=[]
{
"Some simple substitution tests"_test <=TableTest< Alepha::expandVariables >::Cases
{
{
"Hello World",
{ "$H$ $W$", { { "H", lambaste<="Hello" }, { "W", lambaste<="World" } }, '$' },
"Hello World"
},
{
"Hello $$ World",
{ "$H$ $$ $W$", { { "H", lambaste<="Hello" }, { "W", lambaste <="World" } }, '$' },
"Hello $ World"
},
};
"An exception should be thrown when there is a trailing unenclosed variable."_test <=[]
{
try
{
Alepha::expandVariables( "$H$ $W", { { "H", lambaste<="Hello" }, { "W", lambaste<="World" } }, '$' );
abort();
}
catch( ... ) {}
};
};

View File

@ -0,0 +1,3 @@
link_libraries( unit-test )
unit_test( 0 )