mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-19 21:13:35 +00:00
committed by
Konstantin Pastbin
parent
c9cbb64f12
commit
76ffc99abd
90
libs/base/base_tests/uni_string_dfa_test.cpp
Normal file
90
libs/base/base_tests/uni_string_dfa_test.cpp
Normal file
@@ -0,0 +1,90 @@
|
||||
#include "testing/testing.hpp"
|
||||
|
||||
#include "base/dfa_helpers.hpp"
|
||||
#include "base/string_utils.hpp"
|
||||
#include "base/uni_string_dfa.hpp"
|
||||
|
||||
using namespace strings;
|
||||
|
||||
namespace
|
||||
{
|
||||
UNIT_TEST(UniStringDFA_Smoke)
|
||||
{
|
||||
{
|
||||
UniStringDFA dfa("");
|
||||
|
||||
auto it = dfa.Begin();
|
||||
TEST(it.Accepts(), ());
|
||||
TEST(!it.Rejects(), ());
|
||||
|
||||
DFAMove(it, "a");
|
||||
TEST(!it.Accepts(), ());
|
||||
TEST(it.Rejects(), ());
|
||||
}
|
||||
|
||||
{
|
||||
UniStringDFA dfa("абв");
|
||||
|
||||
auto it = dfa.Begin();
|
||||
TEST(!it.Accepts(), ());
|
||||
TEST(!it.Rejects(), ());
|
||||
|
||||
DFAMove(it, "а");
|
||||
TEST(!it.Accepts(), ());
|
||||
TEST(!it.Rejects(), ());
|
||||
|
||||
DFAMove(it, "б");
|
||||
TEST(!it.Accepts(), ());
|
||||
TEST(!it.Rejects(), ());
|
||||
|
||||
DFAMove(it, "в");
|
||||
TEST(it.Accepts(), ());
|
||||
TEST(!it.Rejects(), ());
|
||||
|
||||
DFAMove(it, "г");
|
||||
TEST(!it.Accepts(), ());
|
||||
TEST(it.Rejects(), ());
|
||||
}
|
||||
|
||||
{
|
||||
UniStringDFA dfa("абв");
|
||||
|
||||
auto it = dfa.Begin();
|
||||
TEST(!it.Accepts(), ());
|
||||
TEST(!it.Rejects(), ());
|
||||
|
||||
DFAMove(it, "а");
|
||||
TEST(!it.Accepts(), ());
|
||||
TEST(!it.Rejects(), ());
|
||||
|
||||
DFAMove(it, "г");
|
||||
TEST(!it.Accepts(), ());
|
||||
TEST(it.Rejects(), ());
|
||||
}
|
||||
}
|
||||
|
||||
UNIT_TEST(UniStringDFA_Prefix)
|
||||
{
|
||||
{
|
||||
PrefixDFAModifier<UniStringDFA> dfa(UniStringDFA("abc"));
|
||||
|
||||
auto it = dfa.Begin();
|
||||
DFAMove(it, "ab");
|
||||
|
||||
TEST(!it.Accepts(), ());
|
||||
TEST(!it.Rejects(), ());
|
||||
|
||||
DFAMove(it, "c");
|
||||
TEST(it.Accepts(), ());
|
||||
TEST(!it.Rejects(), ());
|
||||
|
||||
DFAMove(it, "d");
|
||||
TEST(it.Accepts(), ());
|
||||
TEST(!it.Rejects(), ());
|
||||
|
||||
DFAMove(it, "efghijk");
|
||||
TEST(it.Accepts(), ());
|
||||
TEST(!it.Rejects(), ());
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
Reference in New Issue
Block a user