From 1b7d3e0672cee31a5f93d49589aad040d6172e6f Mon Sep 17 00:00:00 2001 From: levlam Date: Fri, 20 Sep 2019 02:14:15 +0300 Subject: [PATCH] Add fix_formatted_text test. GitOrigin-RevId: 995b645cb0d6699abb5bc96f74ac766e8beef9d1 --- test/message_entities.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/test/message_entities.cpp b/test/message_entities.cpp index 09b09deb..1fc22535 100644 --- a/test/message_entities.cpp +++ b/test/message_entities.cpp @@ -9,6 +9,7 @@ #include "td/utils/format.h" #include "td/utils/logging.h" #include "td/utils/tests.h" +#include "td/utils/utf8.h" #include @@ -702,4 +703,21 @@ TEST(MessageEntities, fix_formatted_text) { } } } + + for (auto text : {" \n ➡️ ➡️ ➡️ ➡️ \n ", "\n\n\nab cd ef gh "}) { + str = text; + vector entities; + vector fixed_entities; + + for (int i = 0; i < 10; i++) { + entities.emplace_back(MessageEntity::Type::Bold, (i + 1) * 3, 2); + entities.emplace_back(MessageEntity::Type::Italic, (i + 1) * 3 + 2, 1); + + if (i < 4) { + fixed_entities.emplace_back(MessageEntity::Type::Bold, i * 3, 2); + } + } + + check_fix_formatted_text(str, entities, utf8_utf16_substr(str, 3, 11), fixed_entities, false, false, false, false); + } }