|
@@ -73,13 +73,13 @@ namespace FrameworkTests
|
|
TEST_METHOD (MatchTest3)
|
|
TEST_METHOD (MatchTest3)
|
|
{
|
|
{
|
|
auto parser = Framework::Regex::parse("(?:abc)*");
|
|
auto parser = Framework::Regex::parse("(?:abc)*");
|
|
- auto result = parser->match("_aabcabcc", (int)strlen(" aabcabcc"));
|
|
|
|
|
|
+ auto result = parser->match("_aabcabcc", (int)strlen(" aabcabcc"));
|
|
Assert::IsTrue(result->getEintragAnzahl() == 5,
|
|
Assert::IsTrue(result->getEintragAnzahl() == 5,
|
|
L"Invalid result count while matching '_aabcabcc' against "
|
|
L"Invalid result count while matching '_aabcabcc' against "
|
|
L"'(?:abc)*'");
|
|
L"'(?:abc)*'");
|
|
- auto* first = result->z(0);
|
|
|
|
- auto* second = result->z(1);
|
|
|
|
- auto* third = result->z(2);
|
|
|
|
|
|
+ auto* first = result->z(0);
|
|
|
|
+ auto* second = result->z(1);
|
|
|
|
+ auto* third = result->z(2);
|
|
auto* forth = result->z(3);
|
|
auto* forth = result->z(3);
|
|
auto* fifth = result->z(4);
|
|
auto* fifth = result->z(4);
|
|
Assert::IsTrue(first->getStart() == 0 && first->getEnd() == 0,
|
|
Assert::IsTrue(first->getStart() == 0 && first->getEnd() == 0,
|
|
@@ -127,8 +127,8 @@ namespace FrameworkTests
|
|
auto result = parser->match("_aabcabcc", (int)strlen(" aabcabcc"));
|
|
auto result = parser->match("_aabcabcc", (int)strlen(" aabcabcc"));
|
|
Assert::IsTrue(result->getEintragAnzahl() == 8,
|
|
Assert::IsTrue(result->getEintragAnzahl() == 8,
|
|
L"Invalid result count while matching '_aabcabcc' against "
|
|
L"Invalid result count while matching '_aabcabcc' against "
|
|
- L"'(?:abc)*?'");
|
|
|
|
- auto* _0 = result->z(0);
|
|
|
|
|
|
+ L"'(?:abc)*?'");
|
|
|
|
+ auto* _0 = result->z(0);
|
|
auto* _1 = result->z(1);
|
|
auto* _1 = result->z(1);
|
|
auto* _2 = result->z(2);
|
|
auto* _2 = result->z(2);
|
|
auto* _3 = result->z(3);
|
|
auto* _3 = result->z(3);
|
|
@@ -199,7 +199,8 @@ namespace FrameworkTests
|
|
TEST_METHOD (MatchTest5)
|
|
TEST_METHOD (MatchTest5)
|
|
{
|
|
{
|
|
auto parser = Framework::Regex::parse("(a|b)+");
|
|
auto parser = Framework::Regex::parse("(a|b)+");
|
|
- auto result = parser->match("cabaccccbab", (int)strlen("cabaccccbab"));
|
|
|
|
|
|
+ auto result
|
|
|
|
+ = parser->match("cabaccccbab", (int)strlen("cabaccccbab"));
|
|
Assert::IsTrue(result->getEintragAnzahl() == 2,
|
|
Assert::IsTrue(result->getEintragAnzahl() == 2,
|
|
L"Invalid result count while matching 'cabaccccbab' against "
|
|
L"Invalid result count while matching 'cabaccccbab' against "
|
|
L"'a|b'");
|
|
L"'a|b'");
|
|
@@ -236,8 +237,7 @@ namespace FrameworkTests
|
|
TEST_METHOD (MatchTest6)
|
|
TEST_METHOD (MatchTest6)
|
|
{
|
|
{
|
|
auto parser = Framework::Regex::parse("(?:^|c)ab");
|
|
auto parser = Framework::Regex::parse("(?:^|c)ab");
|
|
- auto result
|
|
|
|
- = parser->match("abcabcasd", (int)strlen("abcabcasd"));
|
|
|
|
|
|
+ auto result = parser->match("abcabcasd", (int)strlen("abcabcasd"));
|
|
Assert::IsTrue(result->getEintragAnzahl() == 2,
|
|
Assert::IsTrue(result->getEintragAnzahl() == 2,
|
|
L"Invalid result count while matching 'abcabcasd' against "
|
|
L"Invalid result count while matching 'abcabcasd' against "
|
|
L"'(?:^|c)ab'");
|
|
L"'(?:^|c)ab'");
|
|
@@ -286,5 +286,54 @@ namespace FrameworkTests
|
|
result->release();
|
|
result->release();
|
|
parser->release();
|
|
parser->release();
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ TEST_METHOD (TestNumber0)
|
|
|
|
+ {
|
|
|
|
+ auto parser = Framework::Regex::parse("^[0-9]+$");
|
|
|
|
+ auto* results = parser->match("0", 1);
|
|
|
|
+ bool ok = results->getEintragAnzahl() == 1;
|
|
|
|
+ results->release();
|
|
|
|
+ parser->release();
|
|
|
|
+ Assert::IsTrue(
|
|
|
|
+ ok, L"no result found while matcging '0' against '^[0-9]+$'");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ TEST_METHOD (TestNumber1)
|
|
|
|
+ {
|
|
|
|
+ auto parser = Framework::Regex::parse("^[0-9]+(\\.[0-9]+)?$");
|
|
|
|
+ auto* results = parser->match("0", 1);
|
|
|
|
+ bool ok = results->getEintragAnzahl() == 1;
|
|
|
|
+ results->release();
|
|
|
|
+ parser->release();
|
|
|
|
+ Assert::IsTrue(ok,
|
|
|
|
+ L"no result found while matcging '0' against "
|
|
|
|
+ L"'^[0-9]+(\\.[0-9]+)?$'");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ TEST_METHOD (TestNumber2)
|
|
|
|
+ {
|
|
|
|
+ auto parser = Framework::Regex::parse(
|
|
|
|
+ "^[0-9]+(\\.[0-9]+)?([eE][+-]?[0-9]+)?$");
|
|
|
|
+ auto* results = parser->match("0", 1);
|
|
|
|
+ bool ok = results->getEintragAnzahl() == 1;
|
|
|
|
+ results->release();
|
|
|
|
+ parser->release();
|
|
|
|
+ Assert::IsTrue(ok,
|
|
|
|
+ L"no result found while matcging '0' against "
|
|
|
|
+ L"'^[0-9]+(\\.[0-9]+)?([eE][+-]?[0-9]+)?$'");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ TEST_METHOD (TestNumber3)
|
|
|
|
+ {
|
|
|
|
+ auto parser = Framework::Regex::parse(
|
|
|
|
+ "^[0-9]+(\\.[0-9]+)?([eE][+-]?[0-9]+)?$");
|
|
|
|
+ auto* results = parser->match("1e-3", 1);
|
|
|
|
+ bool ok = results->getEintragAnzahl() == 1;
|
|
|
|
+ results->release();
|
|
|
|
+ parser->release();
|
|
|
|
+ Assert::IsTrue(ok,
|
|
|
|
+ L"no result found while matcging '1e-3' against "
|
|
|
|
+ L"'^[0-9]+(\\.[0-9]+)?([eE][+-]?[0-9]+)?$'");
|
|
|
|
+ }
|
|
};
|
|
};
|
|
} // namespace FrameworkTests
|
|
} // namespace FrameworkTests
|