1 /*
2 * Copyright (c) 2021-2022 Huawei Device Co., Ltd.
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 #include "phone_number_format_mock.h"
16
17 namespace OHOS {
18 namespace Global {
19 namespace I18n {
PhoneNumberFormatMock(const std::string & countryTag,const std::map<std::string,std::string> & options)20 PhoneNumberFormatMock::PhoneNumberFormatMock(const std::string &countryTag,
21 const std::map<std::string, std::string> &options)
22 : PhoneNumberFormat(countryTag, options)
23 {
24 }
25
getBlockedRegionName(const std::string & regionCode,const std::string & language)26 bool PhoneNumberFormatMock::getBlockedRegionName(const std::string& regionCode, const std::string& language)
27 {
28 if (!regionCode.compare("XK")) {
29 return true;
30 } else {
31 return false;
32 }
33 }
34
getCityName(const std::string & language,const std::string & phonenumber,const std::string & locationName)35 std::string PhoneNumberFormatMock::getCityName(const std::string& language, const std::string& phonenumber,
36 const std::string& locationName)
37 {
38 std::string zhLocaleStr = "zh";
39 size_t len = zhLocaleStr.size();
40 std::string phoneNumberPrefix = "861373193";
41 size_t prefixLen = phoneNumberPrefix.size();
42 if (!phonenumber.compare(0, prefixLen, "861373193") && !language.compare(0, len, "zh")) {
43 return "安徽省宣城市2";
44 }
45 if (!phonenumber.compare(0, prefixLen, "861373163") && !language.compare(0, len, "zh")) {
46 return "";
47 }
48 return locationName;
49 }
50 } // namespace I18n
51 } // namespace Global
52 } // namespace OHOS