1
0
forked from Alepha/Alepha

String distance algorithms.

This commit is contained in:
2023-11-17 01:22:30 -05:00
parent 4426fc2857
commit 001de28231
6 changed files with 198 additions and 0 deletions

View File

@ -0,0 +1,35 @@
static_assert( __cplusplus > 2020'99 );
#include "../string_distance.h"
#include <Alepha/Testing/TableTest.h>
#include <Alepha/Testing/test.h>
static auto init= Alepha::Utility::enroll <=[]
{
using namespace Alepha::Testing::exports;
using namespace Alepha::Algorithm::exports::string_distance_m;
"Rewrite string distance examples."_test <=TableTest< rewriteStringDistance >::Cases
{
{ "Simple example of equality"_case, { "Hello World", "Hello World" }, 0 },
{ "Simple example of single substitution"_case, { "Hello Worrd", "Hello World" }, 1 },
{ "Simple example of single addition"_case, { "Hello Worlda", "Hello World" }, 1 },
{ "Simple example of single removal"_case, { "Hello Worl", "Hello World" }, 1 },
{ "Simple example of single transposition"_case, { "Hello Wolrd", "Hello World" }, 2 },
{ "Two transposition"_case, { "xxxabxxxcdxxx", "xxxbaxxxdcxxx" }, 4 },
{ "Reversal case"_case, { "123456789", "987654321" }, 8 },
};
"Optimal string distance examples."_test <=TableTest< optimalStringDistance >::Cases
{
{ "Simple example of equality"_case, { "Hello World", "Hello World" }, 0 },
{ "Simple example of single substitution"_case, { "Hello Worrd", "Hello World" }, 1 },
{ "Simple example of single addition"_case, { "Hello Worlda", "Hello World" }, 1 },
{ "Simple example of single removal"_case, { "Hello Worl", "Hello World" }, 1 },
{ "Simple example of single transposition"_case, { "Hello Wolrd", "Hello World" }, 1 },
{ "Two transposition"_case, { "xxxabxxxcdxxx", "xxxbaxxxdcxxx" }, 2 },
{ "Reversal case"_case, { "123456789", "987654321" }, 8 },
};
};

View File

@ -0,0 +1 @@
unit_test( 0 )