e4182186c1d308b8bf964cc69f0835d9a54b297e
[platform/upstream/libphonenumber.git] / cpp / test / phonenumbers / test_util.cc
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 <iostream>
18 #include <vector>
19
20 #include "phonenumbers/phonenumber.pb.h"
21 #include "phonenumbers/test_util.h"
22
23 using std::cout;
24 using std::endl;
25
26 namespace i18n {
27 namespace phonenumbers {
28
29 ostream& operator<<(ostream& os, const PhoneNumber& number) {
30   os << endl
31      << "country_code: " << number.country_code() << endl
32      << "national_number: " << number.national_number() << endl;
33   if (number.has_extension()) {
34      os << "extension: " << number.extension() << endl;
35   }
36   if (number.has_italian_leading_zero()) {
37      os << "italian_leading_zero: " << number.italian_leading_zero() << endl;
38   }
39   if (number.has_raw_input()) {
40      os << "raw_input: " << number.raw_input() << endl;
41   }
42   if (number.has_country_code_source()) {
43      os << "country_code_source: " << number.country_code_source() << endl;
44   }
45   if (number.has_preferred_domestic_carrier_code()) {
46      os << "preferred_domestic_carrier_code: "
47         << number.preferred_domestic_carrier_code() << endl;
48   }
49   return os;
50 }
51
52 ostream& operator<<(ostream& os, const vector<PhoneNumber>& numbers) {
53   os << "[" << endl;
54   for (vector<PhoneNumber>::const_iterator it = numbers.begin();
55        it != numbers.end(); ++it) {
56     os << *it;
57   }
58   os << endl << "]" << endl;
59   return os;
60 }
61
62 }  // namespace phonenumbers
63 }  // namespace i18n