diff --git a/tdutils/CMakeLists.txt b/tdutils/CMakeLists.txt index 3fcb887c5..de7e26eba 100644 --- a/tdutils/CMakeLists.txt +++ b/tdutils/CMakeLists.txt @@ -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 diff --git a/tdutils/test/emoji.cpp b/tdutils/test/emoji.cpp new file mode 100644 index 000000000..beb130047 --- /dev/null +++ b/tdutils/test/emoji.cpp @@ -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("🧑‍🎄")); +} diff --git a/tdutils/test/misc.cpp b/tdutils/test/misc.cpp index ca21eb600..34a541e5a 100644 --- a/tdutils/test/misc.cpp +++ b/tdutils/test/misc.cpp @@ -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)));