Move is_emoji test to separate file.

This commit is contained in:
levlam 2022-05-12 18:45:25 +03:00
parent de5f047dba
commit 6377a15d02
3 changed files with 30 additions and 22 deletions

View File

@ -305,6 +305,7 @@ set(TDUTILS_TEST_SOURCE
${CMAKE_CURRENT_SOURCE_DIR}/test/ChainScheduler.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test/ConcurrentHashMap.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test/crypto.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test/emoji.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test/Enumerator.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test/EpochBasedMemoryReclamation.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test/filesystem.cpp

29
tdutils/test/emoji.cpp Normal file
View File

@ -0,0 +1,29 @@
//
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022
//
// 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)
//
#include "td/utils/emoji.h"
#include "td/utils/tests.h"
TEST(Misc, is_emoji) {
ASSERT_TRUE(td::is_emoji("πŸ‘©πŸΌβ€β€β€πŸ’‹β€πŸ‘©πŸ»"));
ASSERT_TRUE(td::is_emoji("πŸ‘©πŸΌβ€β€οΈβ€πŸ’‹β€πŸ‘©πŸ»"));
ASSERT_TRUE(!td::is_emoji("πŸ‘©πŸΌβ€β€οΈοΈβ€πŸ’‹β€πŸ‘©πŸ»"));
ASSERT_TRUE(td::is_emoji("⌚"));
ASSERT_TRUE(td::is_emoji("↔"));
ASSERT_TRUE(td::is_emoji("πŸͺ—"));
ASSERT_TRUE(td::is_emoji("2️⃣"));
ASSERT_TRUE(td::is_emoji("2⃣"));
ASSERT_TRUE(!td::is_emoji(" 2⃣"));
ASSERT_TRUE(!td::is_emoji("2⃣ "));
ASSERT_TRUE(!td::is_emoji(" "));
ASSERT_TRUE(!td::is_emoji(""));
ASSERT_TRUE(!td::is_emoji("1234567890123456789012345678901234567890123456789012345678901234567890"));
ASSERT_TRUE(td::is_emoji("❀️"));
ASSERT_TRUE(td::is_emoji("❀"));
ASSERT_TRUE(td::is_emoji("⌚"));
ASSERT_TRUE(td::is_emoji("πŸŽ„"));
ASSERT_TRUE(td::is_emoji("πŸ§‘β€πŸŽ„"));
}

View File

@ -11,7 +11,6 @@
#include "td/utils/bits.h"
#include "td/utils/CancellationToken.h"
#include "td/utils/common.h"
#include "td/utils/emoji.h"
#include "td/utils/ExitGuard.h"
#include "td/utils/Hash.h"
#include "td/utils/HashMap.h"
@ -1215,27 +1214,6 @@ TEST(Misc, uname) {
ASSERT_TRUE(!first_version.empty());
}
TEST(Misc, is_emoji) {
ASSERT_TRUE(td::is_emoji("πŸ‘©πŸΌβ€β€β€πŸ’‹β€πŸ‘©πŸ»"));
ASSERT_TRUE(td::is_emoji("πŸ‘©πŸΌβ€β€οΈβ€πŸ’‹β€πŸ‘©πŸ»"));
ASSERT_TRUE(!td::is_emoji("πŸ‘©πŸΌβ€β€οΈοΈβ€πŸ’‹β€πŸ‘©πŸ»"));
ASSERT_TRUE(td::is_emoji("⌚"));
ASSERT_TRUE(td::is_emoji("↔"));
ASSERT_TRUE(td::is_emoji("πŸͺ—"));
ASSERT_TRUE(td::is_emoji("2️⃣"));
ASSERT_TRUE(td::is_emoji("2⃣"));
ASSERT_TRUE(!td::is_emoji(" 2⃣"));
ASSERT_TRUE(!td::is_emoji("2⃣ "));
ASSERT_TRUE(!td::is_emoji(" "));
ASSERT_TRUE(!td::is_emoji(""));
ASSERT_TRUE(!td::is_emoji("1234567890123456789012345678901234567890123456789012345678901234567890"));
ASSERT_TRUE(td::is_emoji("❀️"));
ASSERT_TRUE(td::is_emoji("❀"));
ASSERT_TRUE(td::is_emoji("⌚"));
ASSERT_TRUE(td::is_emoji("πŸŽ„"));
ASSERT_TRUE(td::is_emoji("πŸ§‘β€πŸŽ„"));
}
TEST(Misc, serialize) {
td::int32 x = 1;
ASSERT_EQ(td::base64_encode(td::serialize(x)), td::base64_encode(td::string("\x01\x00\x00\x00", 4)));