|
|
|
@ -18,186 +18,305 @@ |
|
|
|
#include "phonenumbers/regexp_adapter.h"
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include <gtest/gtest.h>
|
|
|
|
|
|
|
|
#include "base/basictypes.h"
|
|
|
|
#include "base/scoped_ptr.h"
|
|
|
|
#include "stl_util.h"
|
|
|
|
#include "stringutil.h"
|
|
|
|
|
|
|
|
#ifdef USE_RE2
|
|
|
|
#include "phonenumbers/regexp_adapter_re2.h"
|
|
|
|
#else
|
|
|
|
#include "phonenumbers/regexp_adapter_icu.h"
|
|
|
|
#endif // USE_RE2
|
|
|
|
|
|
|
|
namespace i18n { |
|
|
|
namespace phonenumbers { |
|
|
|
|
|
|
|
using std::string; |
|
|
|
using std::vector; |
|
|
|
|
|
|
|
// Structure that contains the attributes used to test an implementation of the
|
|
|
|
// regexp adapter.
|
|
|
|
struct RegExpTestContext { |
|
|
|
explicit RegExpTestContext(const string& name, |
|
|
|
const AbstractRegExpFactory* factory) |
|
|
|
: name(name), |
|
|
|
factory(factory), |
|
|
|
digits(factory->CreateRegExp("\\d+")), |
|
|
|
parentheses_digits(factory->CreateRegExp("\\((\\d+)\\)")), |
|
|
|
single_digit(factory->CreateRegExp("\\d")), |
|
|
|
two_digit_groups(factory->CreateRegExp("(\\d+)-(\\d+)")) {} |
|
|
|
|
|
|
|
const string name; |
|
|
|
const scoped_ptr<const AbstractRegExpFactory> factory; |
|
|
|
const scoped_ptr<const RegExp> digits; |
|
|
|
const scoped_ptr<const RegExp> parentheses_digits; |
|
|
|
const scoped_ptr<const RegExp> single_digit; |
|
|
|
const scoped_ptr<const RegExp> two_digit_groups; |
|
|
|
}; |
|
|
|
|
|
|
|
class RegExpAdapterTest : public testing::Test { |
|
|
|
protected: |
|
|
|
RegExpAdapterTest() |
|
|
|
: digits_(RegExp::Create("\\d+")), |
|
|
|
parentheses_digits_(RegExp::Create("\\((\\d+)\\)")), |
|
|
|
single_digit_(RegExp::Create("\\d")), |
|
|
|
two_digit_groups_(RegExp::Create("(\\d+)-(\\d+)")) {} |
|
|
|
|
|
|
|
const scoped_ptr<const RegExp> digits_; |
|
|
|
const scoped_ptr<const RegExp> parentheses_digits_; |
|
|
|
const scoped_ptr<const RegExp> single_digit_; |
|
|
|
const scoped_ptr<const RegExp> two_digit_groups_; |
|
|
|
RegExpAdapterTest() { |
|
|
|
#ifdef USE_RE2
|
|
|
|
contexts_.push_back( |
|
|
|
new RegExpTestContext("RE2", new RE2RegExpFactory())); |
|
|
|
#else
|
|
|
|
contexts_.push_back( |
|
|
|
new RegExpTestContext("ICU Regex", new ICURegExpFactory())); |
|
|
|
#endif // USE_RE2
|
|
|
|
} |
|
|
|
|
|
|
|
~RegExpAdapterTest() { |
|
|
|
STLDeleteElements(&contexts_); |
|
|
|
} |
|
|
|
|
|
|
|
static string ErrorMessage(const RegExpTestContext& context) { |
|
|
|
return StrCat("Test failed with ", context.name, " implementation."); |
|
|
|
} |
|
|
|
|
|
|
|
typedef vector<const RegExpTestContext*>::const_iterator TestContextIterator; |
|
|
|
vector<const RegExpTestContext*> contexts_; |
|
|
|
}; |
|
|
|
|
|
|
|
TEST_F(RegExpAdapterTest, TestConsumeNoMatch) { |
|
|
|
const scoped_ptr<RegExpInput> input(RegExpInput::Create("+1-123-456-789")); |
|
|
|
|
|
|
|
// When 'true' is passed to Consume(), the match occurs from the beginning of
|
|
|
|
// the input.
|
|
|
|
ASSERT_FALSE(digits_->Consume(input.get(), true, NULL, NULL, NULL)); |
|
|
|
ASSERT_EQ("+1-123-456-789", input->ToString()); |
|
|
|
|
|
|
|
string res1; |
|
|
|
ASSERT_FALSE(parentheses_digits_->Consume( |
|
|
|
input.get(), true, &res1, NULL, NULL)); |
|
|
|
ASSERT_EQ("+1-123-456-789", input->ToString()); |
|
|
|
ASSERT_EQ("", res1); |
|
|
|
for (vector<const RegExpTestContext*>::const_iterator it = contexts_.begin(); |
|
|
|
it != contexts_.end(); |
|
|
|
++it) { |
|
|
|
const RegExpTestContext& context = **it; |
|
|
|
const scoped_ptr<RegExpInput> input( |
|
|
|
context.factory->CreateInput("+1-123-456-789")); |
|
|
|
|
|
|
|
// When 'true' is passed to Consume(), the match occurs from the beginning
|
|
|
|
// of the input.
|
|
|
|
ASSERT_FALSE(context.digits->Consume(input.get(), true, NULL, NULL, NULL)) |
|
|
|
<< ErrorMessage(context); |
|
|
|
ASSERT_EQ("+1-123-456-789", input->ToString()) << ErrorMessage(context); |
|
|
|
|
|
|
|
string res1; |
|
|
|
ASSERT_FALSE(context.parentheses_digits->Consume( |
|
|
|
input.get(), true, &res1, NULL, NULL)) << ErrorMessage(context); |
|
|
|
ASSERT_EQ("+1-123-456-789", input->ToString()) << ErrorMessage(context); |
|
|
|
ASSERT_EQ("", res1) << ErrorMessage(context); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
TEST_F(RegExpAdapterTest, TestConsumeWithNull) { |
|
|
|
const scoped_ptr<RegExpInput> input(RegExpInput::Create("+123")); |
|
|
|
const scoped_ptr<const RegExp> plus_sign(RegExp::Create("(\\+)")); |
|
|
|
|
|
|
|
ASSERT_TRUE(plus_sign->Consume(input.get(), true, NULL, NULL, NULL)); |
|
|
|
ASSERT_EQ("123", input->ToString()); |
|
|
|
for (TestContextIterator it = contexts_.begin(); it != contexts_.end(); |
|
|
|
++it) { |
|
|
|
const RegExpTestContext& context = **it; |
|
|
|
const AbstractRegExpFactory& factory = *context.factory; |
|
|
|
const scoped_ptr<RegExpInput> input(factory.CreateInput("+123")); |
|
|
|
const scoped_ptr<const RegExp> plus_sign(factory.CreateRegExp("(\\+)")); |
|
|
|
|
|
|
|
ASSERT_TRUE(plus_sign->Consume(input.get(), true, NULL, NULL, NULL)) |
|
|
|
<< ErrorMessage(context); |
|
|
|
ASSERT_EQ("123", input->ToString()) << ErrorMessage(context); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
TEST_F(RegExpAdapterTest, TestConsumeRetainsMatches) { |
|
|
|
const scoped_ptr<RegExpInput> input(RegExpInput::Create("1-123-456-789")); |
|
|
|
|
|
|
|
string res1, res2; |
|
|
|
ASSERT_TRUE(two_digit_groups_->Consume( |
|
|
|
input.get(), true, &res1, &res2, NULL)); |
|
|
|
ASSERT_EQ("-456-789", input->ToString()); |
|
|
|
ASSERT_EQ("1", res1); |
|
|
|
ASSERT_EQ("123", res2); |
|
|
|
for (TestContextIterator it = contexts_.begin(); it != contexts_.end(); |
|
|
|
++it) { |
|
|
|
const RegExpTestContext& context = **it; |
|
|
|
const scoped_ptr<RegExpInput> input( |
|
|
|
context.factory->CreateInput("1-123-456-789")); |
|
|
|
|
|
|
|
string res1, res2; |
|
|
|
ASSERT_TRUE(context.two_digit_groups->Consume( |
|
|
|
input.get(), true, &res1, &res2, NULL)) << ErrorMessage(context); |
|
|
|
ASSERT_EQ("-456-789", input->ToString()) << ErrorMessage(context); |
|
|
|
ASSERT_EQ("1", res1) << ErrorMessage(context); |
|
|
|
ASSERT_EQ("123", res2) << ErrorMessage(context); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
TEST_F(RegExpAdapterTest, TestFindAndConsume) { |
|
|
|
const scoped_ptr<RegExpInput> input(RegExpInput::Create("+1-123-456-789")); |
|
|
|
|
|
|
|
// When 'false' is passed to Consume(), the match can occur from any place in
|
|
|
|
// the input.
|
|
|
|
ASSERT_TRUE(digits_->Consume(input.get(), false, NULL, NULL, NULL)); |
|
|
|
ASSERT_EQ("-123-456-789", input->ToString()); |
|
|
|
|
|
|
|
ASSERT_TRUE(digits_->Consume(input.get(), false, NULL, NULL, NULL)); |
|
|
|
ASSERT_EQ("-456-789", input->ToString()); |
|
|
|
|
|
|
|
ASSERT_FALSE(parentheses_digits_->Consume( |
|
|
|
input.get(), false, NULL, NULL, NULL)); |
|
|
|
ASSERT_EQ("-456-789", input->ToString()); |
|
|
|
|
|
|
|
string res1, res2; |
|
|
|
ASSERT_TRUE(two_digit_groups_->Consume( |
|
|
|
input.get(), false, &res1, &res2, NULL)); |
|
|
|
ASSERT_EQ("", input->ToString()); |
|
|
|
ASSERT_EQ("456", res1); |
|
|
|
ASSERT_EQ("789", res2); |
|
|
|
for (TestContextIterator it = contexts_.begin(); it != contexts_.end(); |
|
|
|
++it) { |
|
|
|
const RegExpTestContext& context = **it; |
|
|
|
const scoped_ptr<RegExpInput> input( |
|
|
|
context.factory->CreateInput("+1-123-456-789")); |
|
|
|
|
|
|
|
// When 'false' is passed to Consume(), the match can occur from any place
|
|
|
|
// in the input.
|
|
|
|
ASSERT_TRUE(context.digits->Consume(input.get(), false, NULL, NULL, NULL)) |
|
|
|
<< ErrorMessage(context); |
|
|
|
ASSERT_EQ("-123-456-789", input->ToString()) << ErrorMessage(context); |
|
|
|
|
|
|
|
ASSERT_TRUE(context.digits->Consume(input.get(), false, NULL, NULL, NULL)) |
|
|
|
<< ErrorMessage(context); |
|
|
|
ASSERT_EQ("-456-789", input->ToString()) << ErrorMessage(context); |
|
|
|
|
|
|
|
ASSERT_FALSE(context.parentheses_digits->Consume( |
|
|
|
input.get(), false, NULL, NULL, NULL)) << ErrorMessage(context); |
|
|
|
ASSERT_EQ("-456-789", input->ToString()) << ErrorMessage(context); |
|
|
|
|
|
|
|
string res1, res2; |
|
|
|
ASSERT_TRUE(context.two_digit_groups->Consume( |
|
|
|
input.get(), false, &res1, &res2, NULL)) << ErrorMessage(context); |
|
|
|
ASSERT_EQ("", input->ToString()) << ErrorMessage(context); |
|
|
|
ASSERT_EQ("456", res1) << ErrorMessage(context); |
|
|
|
ASSERT_EQ("789", res2) << ErrorMessage(context); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
TEST(RegExpAdapter, TestPartialMatch) { |
|
|
|
const scoped_ptr<const RegExp> reg_exp(RegExp::Create("([\\da-z]+)")); |
|
|
|
string matched; |
|
|
|
|
|
|
|
EXPECT_TRUE(reg_exp->PartialMatch("12345af", &matched)); |
|
|
|
EXPECT_EQ("12345af", matched); |
|
|
|
|
|
|
|
EXPECT_TRUE(reg_exp->PartialMatch("12345af", NULL)); |
|
|
|
|
|
|
|
EXPECT_TRUE(reg_exp->PartialMatch("[12]", &matched)); |
|
|
|
EXPECT_EQ("12", matched); |
|
|
|
|
|
|
|
matched.clear(); |
|
|
|
EXPECT_FALSE(reg_exp->PartialMatch("[]", &matched)); |
|
|
|
EXPECT_EQ("", matched); |
|
|
|
TEST_F(RegExpAdapterTest, TestPartialMatch) { |
|
|
|
for (TestContextIterator it = contexts_.begin(); it != contexts_.end(); |
|
|
|
++it) { |
|
|
|
const RegExpTestContext& context = **it; |
|
|
|
const AbstractRegExpFactory& factory = *context.factory; |
|
|
|
const scoped_ptr<const RegExp> reg_exp(factory.CreateRegExp("([\\da-z]+)")); |
|
|
|
string matched; |
|
|
|
|
|
|
|
EXPECT_TRUE(reg_exp->PartialMatch("12345af", &matched)) |
|
|
|
<< ErrorMessage(context); |
|
|
|
EXPECT_EQ("12345af", matched) << ErrorMessage(context); |
|
|
|
|
|
|
|
EXPECT_TRUE(reg_exp->PartialMatch("12345af", NULL)) |
|
|
|
<< ErrorMessage(context); |
|
|
|
|
|
|
|
EXPECT_TRUE(reg_exp->PartialMatch("[12]", &matched)) |
|
|
|
<< ErrorMessage(context); |
|
|
|
EXPECT_EQ("12", matched) << ErrorMessage(context); |
|
|
|
|
|
|
|
matched.clear(); |
|
|
|
EXPECT_FALSE(reg_exp->PartialMatch("[]", &matched)) |
|
|
|
<< ErrorMessage(context); |
|
|
|
EXPECT_EQ("", matched) << ErrorMessage(context); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
TEST(RegExpAdapter, TestFullMatch) { |
|
|
|
const scoped_ptr<const RegExp> reg_exp(RegExp::Create("([\\da-z]+)")); |
|
|
|
string matched; |
|
|
|
TEST_F(RegExpAdapterTest, TestFullMatch) { |
|
|
|
for (TestContextIterator it = contexts_.begin(); it != contexts_.end(); |
|
|
|
++it) { |
|
|
|
const RegExpTestContext& context = **it; |
|
|
|
const AbstractRegExpFactory& factory = *context.factory; |
|
|
|
const scoped_ptr<const RegExp> reg_exp(factory.CreateRegExp("([\\da-z]+)")); |
|
|
|
string matched; |
|
|
|
|
|
|
|
EXPECT_TRUE(reg_exp->FullMatch("12345af", &matched)); |
|
|
|
EXPECT_EQ("12345af", matched); |
|
|
|
EXPECT_TRUE(reg_exp->FullMatch("12345af", &matched)) |
|
|
|
<< ErrorMessage(context); |
|
|
|
EXPECT_EQ("12345af", matched) << ErrorMessage(context); |
|
|
|
|
|
|
|
EXPECT_TRUE(reg_exp->FullMatch("12345af", NULL)); |
|
|
|
EXPECT_TRUE(reg_exp->FullMatch("12345af", NULL)) << ErrorMessage(context); |
|
|
|
|
|
|
|
matched.clear(); |
|
|
|
EXPECT_FALSE(reg_exp->FullMatch("[12]", &matched)); |
|
|
|
EXPECT_EQ("", matched); |
|
|
|
matched.clear(); |
|
|
|
EXPECT_FALSE(reg_exp->FullMatch("[12]", &matched)) << ErrorMessage(context); |
|
|
|
EXPECT_EQ("", matched) << ErrorMessage(context); |
|
|
|
|
|
|
|
matched.clear(); |
|
|
|
EXPECT_FALSE(reg_exp->FullMatch("[]", &matched)); |
|
|
|
EXPECT_EQ("", matched); |
|
|
|
matched.clear(); |
|
|
|
EXPECT_FALSE(reg_exp->FullMatch("[]", &matched)) << ErrorMessage(context); |
|
|
|
EXPECT_EQ("", matched) << ErrorMessage(context); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
TEST_F(RegExpAdapterTest, TestReplace) { |
|
|
|
string input("123-4567 "); |
|
|
|
|
|
|
|
ASSERT_TRUE(single_digit_->Replace(&input, "+")); |
|
|
|
ASSERT_EQ("+23-4567 ", input); |
|
|
|
|
|
|
|
ASSERT_TRUE(single_digit_->Replace(&input, "+")); |
|
|
|
ASSERT_EQ("++3-4567 ", input); |
|
|
|
|
|
|
|
const scoped_ptr<const RegExp> single_letter(RegExp::Create("[a-z]")); |
|
|
|
ASSERT_FALSE(single_letter->Replace(&input, "+")); |
|
|
|
ASSERT_EQ("++3-4567 ", input); |
|
|
|
for (vector<const RegExpTestContext*>::const_iterator it = contexts_.begin(); |
|
|
|
it != contexts_.end(); |
|
|
|
++it) { |
|
|
|
const RegExpTestContext& context = **it; |
|
|
|
string input("123-4567 "); |
|
|
|
|
|
|
|
ASSERT_TRUE(context.single_digit->Replace(&input, "+")) |
|
|
|
<< ErrorMessage(context); |
|
|
|
ASSERT_EQ("+23-4567 ", input) << ErrorMessage(context); |
|
|
|
|
|
|
|
ASSERT_TRUE(context.single_digit->Replace(&input, "+")) |
|
|
|
<< ErrorMessage(context); |
|
|
|
ASSERT_EQ("++3-4567 ", input) << ErrorMessage(context); |
|
|
|
|
|
|
|
const scoped_ptr<const RegExp> single_letter( |
|
|
|
context.factory->CreateRegExp("[a-z]")); |
|
|
|
ASSERT_FALSE(single_letter->Replace(&input, "+")) << ErrorMessage(context); |
|
|
|
ASSERT_EQ("++3-4567 ", input) << ErrorMessage(context); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
TEST_F(RegExpAdapterTest, TestReplaceWithGroup) { |
|
|
|
// Make sure referencing groups in the regexp in the replacement string works.
|
|
|
|
// $[0-9] notation is used.
|
|
|
|
string input = "123-4567 abc"; |
|
|
|
ASSERT_TRUE(two_digit_groups_->Replace(&input, "$2")); |
|
|
|
ASSERT_EQ("4567 abc", input); |
|
|
|
|
|
|
|
input = "123-4567"; |
|
|
|
ASSERT_TRUE(two_digit_groups_->Replace(&input, "$1")); |
|
|
|
ASSERT_EQ("123", input); |
|
|
|
|
|
|
|
input = "123-4567"; |
|
|
|
ASSERT_TRUE(two_digit_groups_->Replace(&input, "$2")); |
|
|
|
ASSERT_EQ("4567", input); |
|
|
|
|
|
|
|
input = "123-4567"; |
|
|
|
ASSERT_TRUE(two_digit_groups_->Replace(&input, "$1 $2")); |
|
|
|
ASSERT_EQ("123 4567", input); |
|
|
|
for (TestContextIterator it = contexts_.begin(); it != contexts_.end(); |
|
|
|
++it) { |
|
|
|
const RegExpTestContext& context = **it; |
|
|
|
|
|
|
|
// Make sure referencing groups in the regexp in the replacement string
|
|
|
|
// works. $[0-9] notation is used.
|
|
|
|
string input = "123-4567 abc"; |
|
|
|
ASSERT_TRUE(context.two_digit_groups->Replace(&input, "$2")) |
|
|
|
<< ErrorMessage(context); |
|
|
|
ASSERT_EQ("4567 abc", input) << ErrorMessage(context); |
|
|
|
|
|
|
|
input = "123-4567"; |
|
|
|
ASSERT_TRUE(context.two_digit_groups->Replace(&input, "$1")) |
|
|
|
<< ErrorMessage(context); |
|
|
|
ASSERT_EQ("123", input) << ErrorMessage(context); |
|
|
|
|
|
|
|
input = "123-4567"; |
|
|
|
ASSERT_TRUE(context.two_digit_groups->Replace(&input, "$2")) |
|
|
|
<< ErrorMessage(context); |
|
|
|
ASSERT_EQ("4567", input) << ErrorMessage(context); |
|
|
|
|
|
|
|
input = "123-4567"; |
|
|
|
ASSERT_TRUE(context.two_digit_groups->Replace(&input, "$1 $2")) |
|
|
|
<< ErrorMessage(context); |
|
|
|
ASSERT_EQ("123 4567", input) << ErrorMessage(context); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
TEST_F(RegExpAdapterTest, TestReplaceWithDollarSign) { |
|
|
|
// Make sure '$' can be used in the replacement string when escaped.
|
|
|
|
string input = "123-4567"; |
|
|
|
ASSERT_TRUE(two_digit_groups_->Replace(&input, "\\$1 \\$2")); |
|
|
|
ASSERT_EQ("$1 $2", input); |
|
|
|
for (TestContextIterator it = contexts_.begin(); it != contexts_.end(); |
|
|
|
++it) { |
|
|
|
const RegExpTestContext& context = **it; |
|
|
|
|
|
|
|
// Make sure '$' can be used in the replacement string when escaped.
|
|
|
|
string input = "123-4567"; |
|
|
|
ASSERT_TRUE(context.two_digit_groups->Replace(&input, "\\$1 \\$2")) |
|
|
|
<< ErrorMessage(context); |
|
|
|
|
|
|
|
ASSERT_EQ("$1 $2", input) << ErrorMessage(context); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
TEST_F(RegExpAdapterTest, TestGlobalReplace) { |
|
|
|
string input("123-4567 "); |
|
|
|
for (TestContextIterator it = contexts_.begin(); it != contexts_.end(); |
|
|
|
++it) { |
|
|
|
const RegExpTestContext& context = **it; |
|
|
|
|
|
|
|
string input("123-4567 "); |
|
|
|
|
|
|
|
ASSERT_TRUE(single_digit_->GlobalReplace(&input, "*")); |
|
|
|
ASSERT_EQ("***-**** ", input); |
|
|
|
ASSERT_TRUE(context.single_digit->GlobalReplace(&input, "*")) |
|
|
|
<< ErrorMessage(context); |
|
|
|
ASSERT_EQ("***-**** ", input) << ErrorMessage(context); |
|
|
|
|
|
|
|
ASSERT_FALSE(single_digit_->GlobalReplace(&input, "*")); |
|
|
|
ASSERT_EQ("***-**** ", input); |
|
|
|
ASSERT_FALSE(context.single_digit->GlobalReplace(&input, "*")) |
|
|
|
<< ErrorMessage(context); |
|
|
|
ASSERT_EQ("***-**** ", input) << ErrorMessage(context); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
TEST(RegExpAdapter, TestUtf8) { |
|
|
|
const scoped_ptr<const RegExp> reg_exp(RegExp::Create( |
|
|
|
"\xE2\x84\xA1\xE2\x8A\x8F([\xCE\xB1-\xCF\x89]*)\xE2\x8A\x90" |
|
|
|
/* "℡⊏([α-ω]*)⊐" */)); |
|
|
|
string matched; |
|
|
|
|
|
|
|
EXPECT_FALSE(reg_exp->Match( |
|
|
|
"\xE2\x84\xA1\xE2\x8A\x8F" "123\xE2\x8A\x90" /* "℡⊏123⊐" */, true, |
|
|
|
&matched)); |
|
|
|
EXPECT_TRUE(reg_exp->Match( |
|
|
|
"\xE2\x84\xA1\xE2\x8A\x8F\xCE\xB1\xCE\xB2\xE2\x8A\x90" |
|
|
|
/* "℡⊏αβ⊐" */, true, &matched)); |
|
|
|
EXPECT_EQ("\xCE\xB1\xCE\xB2" /* "αβ" */, matched); |
|
|
|
TEST_F(RegExpAdapterTest, TestUtf8) { |
|
|
|
for (TestContextIterator it = contexts_.begin(); it != contexts_.end(); |
|
|
|
++it) { |
|
|
|
const RegExpTestContext& context = **it; |
|
|
|
const AbstractRegExpFactory& factory = *context.factory; |
|
|
|
|
|
|
|
const scoped_ptr<const RegExp> reg_exp(factory.CreateRegExp( |
|
|
|
"\xE2\x84\xA1\xE2\x8A\x8F([\xCE\xB1-\xCF\x89]*)\xE2\x8A\x90" |
|
|
|
/* "℡⊏([α-ω]*)⊐" */)); |
|
|
|
string matched; |
|
|
|
|
|
|
|
EXPECT_FALSE(reg_exp->Match( |
|
|
|
"\xE2\x84\xA1\xE2\x8A\x8F" "123\xE2\x8A\x90" /* "℡⊏123⊐" */, true, |
|
|
|
&matched)) << ErrorMessage(context); |
|
|
|
EXPECT_TRUE(reg_exp->Match( |
|
|
|
"\xE2\x84\xA1\xE2\x8A\x8F\xCE\xB1\xCE\xB2\xE2\x8A\x90" |
|
|
|
/* "℡⊏αβ⊐" */, true, &matched)) << ErrorMessage(context); |
|
|
|
|
|
|
|
EXPECT_EQ("\xCE\xB1\xCE\xB2" /* "αβ" */, matched) << ErrorMessage(context); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} // namespace phonenumbers
|
|
|
|
|