0a3957dac50a6de900fe066eaf90ded67b4954df
[platform/upstream/libphonenumber.git] / cpp / test / phonenumbers / test_util.h
1 // Copyright (C) 2011 The Libphonenumber Authors
2 //
3 // Licensed under the Apache License, Version 2.0 (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
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 // Author: Philippe Liard
16
17 #include <string>
18 #include <ostream>
19 #include <vector>
20
21 #include "phonenumbers/phonenumber.h"
22
23 namespace i18n {
24 namespace phonenumbers {
25
26 using std::string;
27 using std::ostream;
28 using std::vector;
29
30 class PhoneNumber;
31
32 // Provides PhoneNumber comparison operators to support the use of EXPECT_EQ and
33 // EXPECT_NE in the unittests.
34 inline bool operator==(const PhoneNumber& number1, const PhoneNumber& number2) {
35   return ExactlySameAs(number1, number2);
36 }
37
38 inline bool operator!=(const PhoneNumber& number1, const PhoneNumber& number2) {
39   return !(number1 == number2);
40 }
41
42 // Needed by Google Test to display errors.
43 ostream& operator<<(ostream& os, const PhoneNumber& number);
44
45 ostream& operator<<(ostream& os, const vector<PhoneNumber>& numbers);
46
47 // Class containing string constants of region codes for easier testing. Note
48 // that another private RegionCode class is defined in
49 // cpp/src/phonenumbers/region_code.h. This one contains more constants.
50 class RegionCode {
51  public:
52   static const char* AD() {
53     return "AD";
54   }
55
56   static const char* AO() {
57     return "AO";
58   }
59
60   static const char* AQ() {
61     return "AQ";
62   }
63
64   static const char* AR() {
65     return "AR";
66   }
67
68   static const char* AU() {
69     return "AU";
70   }
71
72   static const char* BR() {
73     return "BR";
74   }
75
76   static const char* BS() {
77     return "BS";
78   }
79
80   static const char* CA() {
81     return "CA";
82   }
83
84   static const char* CN() {
85     return "CN";
86   }
87
88   static const char* CS() {
89     return "CS";
90   }
91
92   static const char* DE() {
93     return "DE";
94   }
95
96   static const char* GB() {
97     return "GB";
98   }
99
100   static const char* IT() {
101     return "IT";
102   }
103
104   static const char* JP() {
105     return "JP";
106   }
107
108   static const char* KR() {
109     return "KR";
110   }
111
112   static const char* MX() {
113     return "MX";
114   }
115
116   static const char* NZ() {
117     return "NZ";
118   }
119
120   static const char* PL() {
121     return "PL";
122   }
123
124   static const char* RE() {
125     return "RE";
126   }
127
128   static const char* SG() {
129     return "SG";
130   }
131
132   static const char* UN001() {
133     return "001";
134   }
135
136   static const char* US() {
137     return "US";
138   }
139
140   static const char* YT() {
141     return "YT";
142   }
143
144   static const char* ZW() {
145     return "ZW";
146   }
147
148   // Returns a region code string representing the "unknown" region.
149   static const char* GetUnknown() {
150     return "ZZ";
151   }
152
153   static const char* ZZ() {
154     return GetUnknown();
155   }
156 };
157
158 }  // namespace phonenumbers
159 }  // namespace i18n