1 // Copyright (C) 2012 The Libphonenumber Authors
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
7 // http://www.apache.org/licenses/LICENSE-2.0
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.
15 // Sample program using the geocoding functionality. This is used to test that
16 // the geocoding library is compiled correctly.
21 #include "phonenumbers/base/logging.h"
22 #include "phonenumbers/geocoding/phonenumber_offline_geocoder.h"
23 #include "phonenumbers/phonenumber.pb.h"
24 #include "phonenumbers/phonenumberutil.h"
26 using i18n::phonenumbers::PhoneNumber;
27 using i18n::phonenumbers::PhoneNumberOfflineGeocoder;
28 using i18n::phonenumbers::PhoneNumberUtil;
32 const PhoneNumberUtil& phone_util = *PhoneNumberUtil::GetInstance();
33 const PhoneNumberUtil::ErrorType status = phone_util.Parse(
34 "16502530000", "US", &number);
35 CHECK_EQ(status, PhoneNumberUtil::NO_PARSING_ERROR);
37 const std::string description =
38 PhoneNumberOfflineGeocoder().GetDescriptionForNumber(
39 number, icu::Locale("en", "GB"));
40 std::cout << description << std::endl;
41 CHECK_EQ(description, "Mountain View, CA");