mirror of https://github.com/procxx/kepka.git
tests: add test for getting suggestion emoji
It more like selective test for getting at lest two working smilies (cat and skull with bones).
This commit is contained in:
parent
370a6f8fef
commit
a5decc802f
|
@ -9,3 +9,26 @@ add_test(NAME flatMapTest COMMAND tests_flat_map)
|
|||
add_executable(tests_flat_set flat_set_tests.cpp)
|
||||
target_link_libraries(tests_flat_set Qt5::Core)
|
||||
add_test(NAME flatSetTest COMMAND tests_flat_set)
|
||||
|
||||
|
||||
add_executable(tests_emojis tests_emojis.cpp
|
||||
$<TARGET_PROPERTY:Kepka,BINARY_DIR>/emoji.cpp
|
||||
$<TARGET_PROPERTY:Kepka,BINARY_DIR>/emoji_suggestions_data.cpp
|
||||
# man, half part of tdesktop, bleat'.
|
||||
$<TARGET_PROPERTY:Kepka,SOURCE_DIR>/SourceFiles/ui/emoji_config.cpp
|
||||
$<TARGET_PROPERTY:Kepka,SOURCE_DIR>/ThirdParty/emoji_suggestions/emoji_suggestions.cpp
|
||||
# damned emojis wants logs. DO NOT WANT. STUB IT.
|
||||
# $<TARGET_PROPERTY:Kepka,SOURCE_DIR>/SourceFiles/logs.cpp
|
||||
|
||||
)
|
||||
|
||||
# force UTF-8 on MSVC or else test will fail.
|
||||
if (MSVC)
|
||||
target_compile_options(tests_emojis PRIVATE "/utf-8")
|
||||
endif()
|
||||
|
||||
# For autogenerated emoji.h
|
||||
# target_compile_definitions(tests_emojis PRIVATE TDESKTOP_DISABLE_CRASH_REPORTS)
|
||||
target_include_directories(tests_emojis PRIVATE $<TARGET_PROPERTY:Kepka,BINARY_DIR>)
|
||||
target_link_libraries(tests_emojis Qt5::Core Qt5::GuiPrivate Qt5::Widgets) # Qt5::Network)
|
||||
add_test(NAME emojisTest COMMAND tests_emojis)
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
/// @file tests_emojis.cpp Tests several emojis for making sure that it
|
||||
/// actually find required emoji.
|
||||
#include "emoji_suggestions.h"
|
||||
#include "emoji_suggestions_data.h"
|
||||
#include <cassert>
|
||||
#include <iostream>
|
||||
#include <QString>
|
||||
#include <QVector>
|
||||
#include <QPair>
|
||||
#include <QMap>
|
||||
#include <string>
|
||||
#include "ui/emoji_config.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
auto str = std::u16string(u":cat:");
|
||||
auto vec = Ui::Emoji::internal::GetReplacements(str[1]); // needs for init internal emoji table.
|
||||
assert(vec != nullptr);
|
||||
auto emoji = Ui::Emoji::internal::GetReplacementEmoji(str);
|
||||
auto cat_u16 = std::u16string(u"🐱");
|
||||
auto cat_w = std::wstring(L"🐱");
|
||||
auto cat_u8 = std::string(u8"🐱"); // u8string in c++20.
|
||||
assert(cat_u16[0] == 0xd83d); // assert that compiler correctly sets charset.
|
||||
assert(cat_w[0] == 0xd83d); // ...in all available charsets.
|
||||
assert(emoji == cat_u16); // simple test that :cat: is really 🐱
|
||||
assert(u"☠️" == Ui::Emoji::internal::GetReplacementEmoji(u":skull_and_crossbones:")); // ditto for ☠️
|
||||
return 0;
|
||||
}
|
||||
|
||||
// stubs for linking (because we do not want to include whole tdesktop)
|
||||
|
||||
DBIScale gRealScale;
|
||||
DBIScale gScreenScale;
|
||||
bool gRetina;
|
||||
QVector <QPair<const Ui::Emoji::One *, unsigned short>> gRecentEmoji;
|
||||
QVector <QPair<QString, unsigned short>> gRecentEmojiPreload;
|
||||
QMap<QString, int> gEmojiVariants;
|
||||
|
||||
namespace SignalHandlers {
|
||||
void setCrashAnnotation(std::string const &, QString const &) {}
|
||||
}
|
||||
|
||||
namespace Logs {
|
||||
void writeMain(QString const &message) {
|
||||
std::cout << message.toStdString();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue