summaryrefslogtreecommitdiffstats
path: root/cpp/test/phonenumbers/test_util.h
blob: 0a3957dac50a6de900fe066eaf90ded67b4954df (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
// Copyright (C) 2011 The Libphonenumber Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// Author: Philippe Liard

#include <string>
#include <ostream>
#include <vector>

#include "phonenumbers/phonenumber.h"

namespace i18n {
namespace phonenumbers {

using std::string;
using std::ostream;
using std::vector;

class PhoneNumber;

// Provides PhoneNumber comparison operators to support the use of EXPECT_EQ and
// EXPECT_NE in the unittests.
inline bool operator==(const PhoneNumber& number1, const PhoneNumber& number2) {
  return ExactlySameAs(number1, number2);
}

inline bool operator!=(const PhoneNumber& number1, const PhoneNumber& number2) {
  return !(number1 == number2);
}

// Needed by Google Test to display errors.
ostream& operator<<(ostream& os, const PhoneNumber& number);

ostream& operator<<(ostream& os, const vector<PhoneNumber>& numbers);

// Class containing string constants of region codes for easier testing. Note
// that another private RegionCode class is defined in
// cpp/src/phonenumbers/region_code.h. This one contains more constants.
class RegionCode {
 public:
  static const char* AD() {
    return "AD";
  }

  static const char* AO() {
    return "AO";
  }

  static const char* AQ() {
    return "AQ";
  }

  static const char* AR() {
    return "AR";
  }

  static const char* AU() {
    return "AU";
  }

  static const char* BR() {
    return "BR";
  }

  static const char* BS() {
    return "BS";
  }

  static const char* CA() {
    return "CA";
  }

  static const char* CN() {
    return "CN";
  }

  static const char* CS() {
    return "CS";
  }

  static const char* DE() {
    return "DE";
  }

  static const char* GB() {
    return "GB";
  }

  static const char* IT() {
    return "IT";
  }

  static const char* JP() {
    return "JP";
  }

  static const char* KR() {
    return "KR";
  }

  static const char* MX() {
    return "MX";
  }

  static const char* NZ() {
    return "NZ";
  }

  static const char* PL() {
    return "PL";
  }

  static const char* RE() {
    return "RE";
  }

  static const char* SG() {
    return "SG";
  }

  static const char* UN001() {
    return "001";
  }

  static const char* US() {
    return "US";
  }

  static const char* YT() {
    return "YT";
  }

  static const char* ZW() {
    return "ZW";
  }

  // Returns a region code string representing the "unknown" region.
  static const char* GetUnknown() {
    return "ZZ";
  }

  static const char* ZZ() {
    return GetUnknown();
  }
};

}  // namespace phonenumbers
}  // namespace i18n