OLD | NEW |
1 // Copyright (C) 2009 The Libphonenumber Authors | 1 // Copyright (C) 2009 The Libphonenumber Authors |
2 // | 2 // |
3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
4 // you may not use this file except in compliance with the License. | 4 // you may not use this file except in compliance with the License. |
5 // You may obtain a copy of the License at | 5 // You may obtain a copy of the License at |
6 // | 6 // |
7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
8 // | 8 // |
9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
(...skipping 12 matching lines...) Expand all Loading... |
23 #include "phonenumbers/phonenumberutil.h" | 23 #include "phonenumbers/phonenumberutil.h" |
24 | 24 |
25 #include <algorithm> | 25 #include <algorithm> |
26 #include <iostream> | 26 #include <iostream> |
27 #include <list> | 27 #include <list> |
28 #include <set> | 28 #include <set> |
29 #include <string> | 29 #include <string> |
30 | 30 |
31 #include <gtest/gtest.h> | 31 #include <gtest/gtest.h> |
32 | 32 |
| 33 #include "phonenumbers/default_logger.h" |
33 #include "phonenumbers/phonemetadata.pb.h" | 34 #include "phonenumbers/phonemetadata.pb.h" |
34 #include "phonenumbers/phonenumber.h" | 35 #include "phonenumbers/phonenumber.h" |
35 #include "phonenumbers/phonenumber.pb.h" | 36 #include "phonenumbers/phonenumber.pb.h" |
36 #include "phonenumbers/test_util.h" | 37 #include "phonenumbers/test_util.h" |
37 | 38 |
38 namespace i18n { | 39 namespace i18n { |
39 namespace phonenumbers { | 40 namespace phonenumbers { |
40 | 41 |
41 using std::endl; | 42 using std::endl; |
42 using std::find; | 43 using std::find; |
43 using std::make_pair; | 44 using std::make_pair; |
44 using std::ostream; | 45 using std::ostream; |
45 | 46 |
46 using google::protobuf::RepeatedPtrField; | 47 using google::protobuf::RepeatedPtrField; |
47 | 48 |
48 static const int kInvalidCountryCode = 2; | 49 static const int kInvalidCountryCode = 2; |
49 | 50 |
50 class PhoneNumberUtilTest : public testing::Test { | 51 class PhoneNumberUtilTest : public testing::Test { |
51 protected: | 52 protected: |
52 PhoneNumberUtilTest() : phone_util_(*PhoneNumberUtil::GetInstance()) { | 53 PhoneNumberUtilTest() : phone_util_(*PhoneNumberUtil::GetInstance()) { |
| 54 PhoneNumberUtil::GetInstance()->SetLogger(new StdoutLogger()); |
53 } | 55 } |
54 | 56 |
55 // Wrapper functions for private functions that we want to test. | 57 // Wrapper functions for private functions that we want to test. |
56 const PhoneMetadata* GetPhoneMetadata(const string& region_code) const { | 58 const PhoneMetadata* GetPhoneMetadata(const string& region_code) const { |
57 return phone_util_.GetMetadataForRegion(region_code); | 59 return phone_util_.GetMetadataForRegion(region_code); |
58 } | 60 } |
59 | 61 |
60 const PhoneMetadata* GetMetadataForNonGeographicalRegion( | 62 const PhoneMetadata* GetMetadataForNonGeographicalRegion( |
61 int country_code) const { | 63 int country_code) const { |
62 return phone_util_.GetMetadataForNonGeographicalRegion(country_code); | 64 return phone_util_.GetMetadataForNonGeographicalRegion(country_code); |
(...skipping 3740 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3803 EXPECT_TRUE(phone_util_.IsAlphaNumber("180 six-flags")); | 3805 EXPECT_TRUE(phone_util_.IsAlphaNumber("180 six-flags")); |
3804 EXPECT_FALSE(phone_util_.IsAlphaNumber("1800 123-1234")); | 3806 EXPECT_FALSE(phone_util_.IsAlphaNumber("1800 123-1234")); |
3805 EXPECT_FALSE(phone_util_.IsAlphaNumber("1 six-flags")); | 3807 EXPECT_FALSE(phone_util_.IsAlphaNumber("1 six-flags")); |
3806 EXPECT_FALSE(phone_util_.IsAlphaNumber("18 six-flags")); | 3808 EXPECT_FALSE(phone_util_.IsAlphaNumber("18 six-flags")); |
3807 EXPECT_FALSE(phone_util_.IsAlphaNumber("1800 123-1234 extension: 1234")); | 3809 EXPECT_FALSE(phone_util_.IsAlphaNumber("1800 123-1234 extension: 1234")); |
3808 EXPECT_FALSE(phone_util_.IsAlphaNumber("+800 1234-1234")); | 3810 EXPECT_FALSE(phone_util_.IsAlphaNumber("+800 1234-1234")); |
3809 } | 3811 } |
3810 | 3812 |
3811 } // namespace phonenumbers | 3813 } // namespace phonenumbers |
3812 } // namespace i18n | 3814 } // namespace i18n |
OLD | NEW |