CPP: libphonenumber v5.7 changes - small improvement to phone number extraction, updates to metadata after build tool changes.

git-svn-id: http://libphonenumber.googlecode.com/svn/trunk/cpp/test@598 ee073f10-1060-11df-b6a4-87a95322a99c
diff --git a/phonenumbers/phonenumbermatcher_test.cc b/phonenumbers/phonenumbermatcher_test.cc
index f19c637..8ef154b 100644
--- a/phonenumbers/phonenumbermatcher_test.cc
+++ b/phonenumbers/phonenumbermatcher_test.cc
@@ -85,6 +85,12 @@
     return PhoneNumberMatcher::IsLatinLetter(letter);
   }
 
+  bool ContainsMoreThanOneSlashInNationalNumber(
+      const PhoneNumber& phone_number, const string& candidate) {
+    return PhoneNumberMatcher::ContainsMoreThanOneSlashInNationalNumber(
+        phone_number, candidate, phone_util_);
+  }
+
   bool ExtractMatch(const string& text, PhoneNumberMatch* match) {
     return matcher_.ExtractMatch(text, offset_, match);
   }
@@ -324,6 +330,52 @@
   int offset_;
 };
 
+TEST_F(PhoneNumberMatcherTest, ContainsMoreThanOneSlashInNationalNumber) {
+  // A date should return true.
+  PhoneNumber number;
+  number.set_country_code(1);
+  number.set_country_code_source(PhoneNumber::FROM_DEFAULT_COUNTRY);
+  string candidate = "1/05/2013";
+  EXPECT_TRUE(ContainsMoreThanOneSlashInNationalNumber(number, candidate));
+
+  // Here, the country code source thinks it started with a country calling
+  // code, but this is not the same as the part before the slash, so it's still
+  // true.
+  number.Clear();
+  number.set_country_code(274);
+  number.set_country_code_source(PhoneNumber::FROM_NUMBER_WITHOUT_PLUS_SIGN);
+  candidate = "27/4/2013";
+  EXPECT_TRUE(ContainsMoreThanOneSlashInNationalNumber(number, candidate));
+
+  // Now it should be false, because the first slash is after the country
+  // calling code.
+  number.Clear();
+  number.set_country_code(49);
+  number.set_country_code_source(PhoneNumber::FROM_NUMBER_WITH_PLUS_SIGN);
+  candidate = "49/69/2013";
+  EXPECT_FALSE(ContainsMoreThanOneSlashInNationalNumber(number, candidate));
+
+  number.Clear();
+  number.set_country_code(49);
+  number.set_country_code_source(PhoneNumber::FROM_NUMBER_WITHOUT_PLUS_SIGN);
+  candidate = "+49/69/2013";
+  EXPECT_FALSE(ContainsMoreThanOneSlashInNationalNumber(number, candidate));
+
+  candidate = "+ 49/69/2013";
+  EXPECT_FALSE(ContainsMoreThanOneSlashInNationalNumber(number, candidate));
+
+  candidate = "+ 49/69/20/13";
+  EXPECT_TRUE(ContainsMoreThanOneSlashInNationalNumber(number, candidate));
+
+  // Here, the first group is not assumed to be the country calling code, even
+  // though it is the same as it, so this should return true.
+  number.Clear();
+  number.set_country_code(49);
+  number.set_country_code_source(PhoneNumber::FROM_DEFAULT_COUNTRY);
+  candidate = "49/69/2013";
+  EXPECT_TRUE(ContainsMoreThanOneSlashInNationalNumber(number, candidate));
+}
+
 // See PhoneNumberUtilTest::ParseNationalNumber.
 TEST_F(PhoneNumberMatcherTest, FindNationalNumber) {
   // Same cases as in ParseNationalNumber.
diff --git a/phonenumbers/phonenumberutil_test.cc b/phonenumbers/phonenumberutil_test.cc
index f170a7b..d9c766b 100644
--- a/phonenumbers/phonenumberutil_test.cc
+++ b/phonenumbers/phonenumberutil_test.cc
@@ -92,6 +92,10 @@
     phone_util_.Normalize(number);
   }
 
+  void NormalizeDiallableCharsOnly(string* number) const {
+    phone_util_.NormalizeDiallableCharsOnly(number);
+  }
+
   bool IsNumberGeographical(const PhoneNumber& phone_number) const {
     return phone_util_.IsNumberGeographical(phone_number);
   }
@@ -148,6 +152,9 @@
   }
 
   const PhoneNumberUtil& phone_util_;
+
+ private:
+  DISALLOW_COPY_AND_ASSIGN(PhoneNumberUtilTest);
 };
 
 TEST_F(PhoneNumberUtilTest, ContainsOnlyValidDigits) {
@@ -2321,6 +2328,14 @@
       << "Conversion did not correctly remove alpha characters";
 }
 
+TEST_F(PhoneNumberUtilTest, NormaliseStripNonDiallableCharacters) {
+  string input_number("03*4-56&+a#234");
+  NormalizeDiallableCharsOnly(&input_number);
+  static const string kExpectedOutput("03*456+234");
+  EXPECT_EQ(kExpectedOutput, input_number)
+      << "Conversion did not correctly remove non-diallable characters";
+}
+
 TEST_F(PhoneNumberUtilTest, MaybeStripInternationalPrefix) {
   string international_prefix("00[39]");
   string number_to_strip("0034567700-3898003");