Tests: Add test for case-insensitive matching

This commit is contained in:
sin-ack 2021-06-16 11:28:06 +00:00 committed by Ali Mohammad Pur
parent 74d76528d6
commit 9a9e7f03f2

View file

@ -4,6 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include "LibRegex/RegexMatcher.h"
#include <LibTest/TestCase.h> // import first, to prevent warning of VERIFY* redefinition
#include <AK/StringBuilder.h>
@ -595,3 +596,12 @@ TEST_CASE(replace)
EXPECT_EQ(re.replace(test.subject, test.replacement), test.expected);
}
}
TEST_CASE(case_insensitive_match)
{
Regex<PosixExtended> re("cd", PosixFlags::Insensitive | PosixFlags::Global);
auto result = re.match("AEKFCD");
EXPECT_EQ(result.success, true);
EXPECT_EQ(result.matches.at(0).column, 4ul);
}