summaryrefslogtreecommitdiff
path: root/protocols/Telegram/tdlib/td/test/country_info.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'protocols/Telegram/tdlib/td/test/country_info.cpp')
-rw-r--r--protocols/Telegram/tdlib/td/test/country_info.cpp59
1 files changed, 37 insertions, 22 deletions
diff --git a/protocols/Telegram/tdlib/td/test/country_info.cpp b/protocols/Telegram/tdlib/td/test/country_info.cpp
index bf88173915..0a9e3c26b6 100644
--- a/protocols/Telegram/tdlib/td/test/country_info.cpp
+++ b/protocols/Telegram/tdlib/td/test/country_info.cpp
@@ -1,5 +1,5 @@
//
-// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022
+// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2023
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
@@ -7,11 +7,13 @@
#include "td/telegram/CountryInfoManager.h"
#include "td/utils/common.h"
+#include "td/utils/logging.h"
#include "td/utils/tests.h"
static void check_phone_number_info(td::string phone_number_prefix, const td::string &country_code,
- const td::string &calling_code, const td::string &formatted_phone_number) {
- auto result = td::CountryInfoManager::get_phone_number_info_sync(td::string(), std::move(phone_number_prefix));
+ const td::string &calling_code, const td::string &formatted_phone_number,
+ bool is_anonymous = false) {
+ auto result = td::CountryInfoManager::get_phone_number_info_sync(td::string(), phone_number_prefix);
CHECK(result != nullptr);
if (result->country_ == nullptr) {
CHECK(country_code.empty());
@@ -19,7 +21,11 @@ static void check_phone_number_info(td::string phone_number_prefix, const td::st
CHECK(result->country_->country_code_ == country_code);
}
CHECK(result->country_calling_code_ == calling_code);
- CHECK(result->formatted_phone_number_ == formatted_phone_number);
+ if (result->formatted_phone_number_ != formatted_phone_number) {
+ LOG(ERROR) << phone_number_prefix << ' ' << result->formatted_phone_number_ << ' ' << formatted_phone_number;
+ CHECK(result->formatted_phone_number_ == formatted_phone_number);
+ }
+ CHECK(result->is_anonymous_ == is_anonymous);
}
TEST(CountryInfo, phone_number_info) {
@@ -52,7 +58,7 @@ TEST(CountryInfo, phone_number_info) {
check_phone_number_info("77654321", "KZ", "7", "765 432 1- --");
check_phone_number_info("3", "", "3", "");
check_phone_number_info("37", "", "37", "");
- check_phone_number_info("372", "EE", "372", "---- ----");
+ check_phone_number_info("372", "EE", "372", "---- ---");
check_phone_number_info("42", "", "42", "");
check_phone_number_info("420", "CZ", "420", "--- --- ---");
check_phone_number_info("421", "SK", "421", "--- --- ---");
@@ -61,27 +67,36 @@ TEST(CountryInfo, phone_number_info) {
check_phone_number_info("424", "YL", "42", "4");
check_phone_number_info("4241234567890", "YL", "42", "41234567890");
check_phone_number_info("4", "", "4", "");
- check_phone_number_info("49", "DE", "49", "---- -------");
- check_phone_number_info("491", "DE", "49", "1--- -------");
- check_phone_number_info("492", "DE", "49", "2--- -------");
- check_phone_number_info("4915", "DE", "49", "15-- -------");
- check_phone_number_info("4916", "DE", "49", "16- -------");
- check_phone_number_info("4917", "DE", "49", "17- -------");
- check_phone_number_info("4918", "DE", "49", "18-- -------");
- check_phone_number_info("493", "DE", "49", "3--- -------");
- check_phone_number_info("4936", "DE", "49", "36-- -------");
- check_phone_number_info("49360", "DE", "49", "360- -------");
- check_phone_number_info("493601", "DE", "49", "3601 -------");
- check_phone_number_info("4936014", "DE", "49", "3601 4------");
- check_phone_number_info("4936015", "DE", "49", "3601 5------");
- check_phone_number_info("493601419", "DE", "49", "3601 419----");
- check_phone_number_info("4936014198", "DE", "49", "3601 4198--");
- check_phone_number_info("49360141980", "DE", "49", "3601 41980-");
+ check_phone_number_info("49", "DE", "49", "");
+ check_phone_number_info("491", "DE", "49", "1");
+ check_phone_number_info("492", "DE", "49", "2");
+ check_phone_number_info("4915", "DE", "49", "15");
+ check_phone_number_info("4916", "DE", "49", "16");
+ check_phone_number_info("4917", "DE", "49", "17");
+ check_phone_number_info("4918", "DE", "49", "18");
+ check_phone_number_info("493", "DE", "49", "3");
+ check_phone_number_info("4936", "DE", "49", "36");
+ check_phone_number_info("49360", "DE", "49", "360");
+ check_phone_number_info("493601", "DE", "49", "3601");
+ check_phone_number_info("4936014", "DE", "49", "36014");
+ check_phone_number_info("4936015", "DE", "49", "36015");
+ check_phone_number_info("493601419", "DE", "49", "3601419");
+ check_phone_number_info("4936014198", "DE", "49", "36014198");
+ check_phone_number_info("49360141980", "DE", "49", "360141980");
check_phone_number_info("841234567890", "VN", "84", "1234567890");
check_phone_number_info("31", "NL", "31", "- -- -- -- --");
check_phone_number_info("318", "NL", "31", "8 -- -- -- --");
check_phone_number_info("319", "NL", "31", "9 -- -- -- --");
check_phone_number_info("3196", "NL", "31", "9 6- -- -- --");
- check_phone_number_info("3197", "NL", "31", "97 ---- -----");
+ check_phone_number_info("3197", "NL", "31", "9 7- -- -- --");
check_phone_number_info("3198", "NL", "31", "9 8- -- -- --");
+ check_phone_number_info("88", "", "88", "");
+ check_phone_number_info("888", "FT", "888", "---- ----", true);
+ check_phone_number_info("8888", "FT", "888", "8 ---", true);
+ check_phone_number_info("88888", "FT", "888", "8 8--", true);
+ check_phone_number_info("888888", "FT", "888", "8 88-", true);
+ check_phone_number_info("8888888", "FT", "888", "8 888", true);
+ check_phone_number_info("88888888", "FT", "888", "8 8888", true);
+ check_phone_number_info("888888888", "FT", "888", "8 88888", true);
+ check_phone_number_info("8888888888", "FT", "888", "8 888888", true);
}