From 0934803ae1e5b4aa52f837beff20183ca6bec6c0 Mon Sep 17 00:00:00 2001 From: miloyip Date: Mon, 25 May 2015 21:57:46 +0800 Subject: [PATCH] Add Unicode regex test --- test/unittest/regextest.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/unittest/regextest.cpp b/test/unittest/regextest.cpp index 1a1bffa..979e230 100644 --- a/test/unittest/regextest.cpp +++ b/test/unittest/regextest.cpp @@ -219,3 +219,14 @@ TEST(Regex, OneOrMore4) { EXPECT_FALSE(re.Match("")); EXPECT_FALSE(re.Match("ab")); } + +TEST(Regex, Unicode) { +#define EURO "\xE2\x82\xAC" // "\xE2\x82\xAC" is UTF-8 sequence of Euro sign U+20AC + Regex re("a" EURO "+b"); + ASSERT_TRUE(re.IsValid()); + EXPECT_TRUE(re.Match("a" EURO "b")); + EXPECT_TRUE(re.Match("a" EURO EURO "b")); + EXPECT_FALSE(re.Match("a?b")); + EXPECT_FALSE(re.Match("a" EURO "\xAC" "b")); // unaware of UTF-8 will match +#undef EURO +}