Update clang-format to 16.0.0.

This commit is contained in:
levlam 2023-02-08 15:28:36 +03:00
parent a08b1f9107
commit 7eee3f469a
6 changed files with 111 additions and 98 deletions

View File

@ -4,15 +4,36 @@ Language: Cpp
AccessModifierOffset: -1 AccessModifierOffset: -1
AlignAfterOpenBracket: Align AlignAfterOpenBracket: Align
AlignArrayOfStructures: None AlignArrayOfStructures: None
AlignConsecutiveMacros: None AlignConsecutiveAssignments:
AlignConsecutiveAssignments: None Enabled: false
AlignConsecutiveBitFields: None AcrossEmptyLines: false
AlignConsecutiveDeclarations: None AcrossComments: false
AlignCompound: false
PadOperators: true
AlignConsecutiveBitFields:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
PadOperators: false
AlignConsecutiveDeclarations:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
PadOperators: false
AlignConsecutiveMacros:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
PadOperators: false
AlignEscapedNewlines: Left AlignEscapedNewlines: Left
AlignOperands: Align AlignOperands: Align
AlignTrailingComments: true AlignTrailingComments:
Kind: Always
OverEmptyLines: 0
AllowAllArgumentsOnNextLine: true AllowAllArgumentsOnNextLine: true
AllowAllConstructorInitializersOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: Never AllowShortBlocksOnASingleLine: Never
AllowShortCaseLabelsOnASingleLine: false AllowShortCaseLabelsOnASingleLine: false
@ -25,6 +46,8 @@ AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: true AlwaysBreakBeforeMultilineStrings: true
AlwaysBreakTemplateDeclarations: Yes AlwaysBreakTemplateDeclarations: Yes
# AttributeMacros:
# - __capability
BinPackArguments: true BinPackArguments: true
BinPackParameters: true BinPackParameters: true
BitFieldColonSpacing: Both BitFieldColonSpacing: Both
@ -33,12 +56,12 @@ BraceWrapping:
AfterClass: false AfterClass: false
AfterControlStatement: Never AfterControlStatement: Never
AfterEnum: false AfterEnum: false
AfterExternBlock: false
AfterFunction: false AfterFunction: false
AfterNamespace: false AfterNamespace: false
AfterObjCDeclaration: false AfterObjCDeclaration: false
AfterStruct: false AfterStruct: false
AfterUnion: false AfterUnion: false
AfterExternBlock: false
BeforeCatch: false BeforeCatch: false
BeforeElse: false BeforeElse: false
BeforeLambdaBody: false BeforeLambdaBody: false
@ -47,24 +70,23 @@ BraceWrapping:
SplitEmptyFunction: true SplitEmptyFunction: true
SplitEmptyRecord: true SplitEmptyRecord: true
SplitEmptyNamespace: true SplitEmptyNamespace: true
BreakAfterAttributes: Never
# BreakAfterJavaFieldAnnotations: false
BreakArrays: true
BreakBeforeBinaryOperators: None BreakBeforeBinaryOperators: None
BreakBeforeBraces: Attach BreakBeforeBraces: Attach
BreakBeforeConceptDeclarations: true BreakBeforeConceptDeclarations: Always
BreakBeforeInheritanceComma: true # false BreakBeforeInlineASMColon: OnlyMultiline
BreakInheritanceList: BeforeComma # BeforeColon
BreakBeforeTernaryOperators: true BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: true # false
BreakConstructorInitializers: BeforeComma # BeforeColon BreakConstructorInitializers: BeforeComma # BeforeColon
# BreakAfterJavaFieldAnnotations: false BreakInheritanceList: BeforeComma # BeforeColon
BreakStringLiterals: true BreakStringLiterals: true
ColumnLimit: 120 # 80 ColumnLimit: 120 # 80
CommentPragmas: '^ IWYU pragma:' CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 4 ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4 ContinuationIndentWidth: 4
Cpp11BracedListStyle: true Cpp11BracedListStyle: true
DeriveLineEnding: true
DerivePointerAlignment: true DerivePointerAlignment: true
DisableFormat: false DisableFormat: false
EmptyLineAfterAccessModifier: Never EmptyLineAfterAccessModifier: Never
@ -83,14 +105,21 @@ IndentCaseLabels: true
IndentExternBlock: AfterExternBlock IndentExternBlock: AfterExternBlock
IndentGotoLabels: true IndentGotoLabels: true
IndentPPDirectives: None IndentPPDirectives: None
IndentRequires: false IndentRequiresClause: true
IndentWidth: 2 IndentWidth: 2
IndentWrappedFunctionNames: false IndentWrappedFunctionNames: false
InsertBraces: false
InsertNewlineAtEOF: false
# InsertTrailingCommas: None # InsertTrailingCommas: None
IntegerLiteralSeparator:
Binary: 0
Decimal: 0
Hex: 0
# JavaScriptQuotes: Leave # JavaScriptQuotes: Leave
# JavaScriptWrapImports: true # JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: false KeepEmptyLinesAtTheStartOfBlocks: false
LambdaBodyIndentation: Signature LambdaBodyIndentation: Signature
LineEnding: DeriveLF
MacroBlockBegin: '' MacroBlockBegin: ''
MacroBlockEnd: '' MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1 MaxEmptyLinesToKeep: 1
@ -100,23 +129,31 @@ NamespaceIndentation: None
# ObjCBreakBeforeNestedBlockParam: true # ObjCBreakBeforeNestedBlockParam: true
# ObjCSpaceAfterProperty: false # ObjCSpaceAfterProperty: false
# ObjCSpaceBeforeProtocolList: true # ObjCSpaceBeforeProtocolList: true
PackConstructorInitializers: NextLine
PenaltyBreakAssignment: 2 PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 1 PenaltyBreakBeforeFirstCallParameter: 1
PenaltyBreakComment: 300 PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120 PenaltyBreakFirstLessLess: 120
PenaltyBreakOpenParenthesis: 0
PenaltyBreakString: 1000 PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10 PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000 PenaltyExcessCharacter: 1000000
PenaltyIndentedWhitespace: 0 PenaltyIndentedWhitespace: 0
PenaltyReturnTypeOnItsOwnLine: 200 PenaltyReturnTypeOnItsOwnLine: 200
PointerAlignment: Right PointerAlignment: Right # Left
PPIndentWidth: -1 PPIndentWidth: -1
QualifierAlignment: Leave
ReferenceAlignment: Pointer ReferenceAlignment: Pointer
ReflowComments: false # true ReflowComments: false # true
RemoveBracesLLVM: false
RemoveSemicolon: false
RequiresClausePosition: OwnLine
RequiresExpressionIndentation: OuterScope
SeparateDefinitionBlocks: Leave
ShortNamespaceLines: 0 # 1 ShortNamespaceLines: 0 # 1
SortIncludes: CaseInsensitive # CaseSensitive SortIncludes: CaseInsensitive # CaseSensitive
# SortJavaStaticImport: Before # SortJavaStaticImport: Before
SortUsingDeclarations: false # true SortUsingDeclarations: Lexicographic # LexicographicNumeric
SpaceAfterCStyleCast: false SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: true SpaceAfterTemplateKeyword: true
@ -127,6 +164,16 @@ SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements SpaceBeforeParens: ControlStatements
SpaceBeforeParensOptions:
AfterControlStatements: true
AfterForeachMacros: true
AfterFunctionDefinitionName: false
AfterFunctionDeclarationName: false
AfterIfMacros: true
AfterOverloadedOperator: false
AfterRequiresInClause: false
AfterRequiresInExpression: false
BeforeNonEmptyParentheses: false
SpaceBeforeRangeBasedForLoopColon: true SpaceBeforeRangeBasedForLoopColon: true
SpaceBeforeSquareBrackets: false SpaceBeforeSquareBrackets: false
SpaceInEmptyBlock: false SpaceInEmptyBlock: false
@ -143,6 +190,5 @@ SpacesInParentheses: false
SpacesInSquareBrackets: false SpacesInSquareBrackets: false
Standard: Auto Standard: Auto
TabWidth: 100 # 8 TabWidth: 100 # 8
UseCRLF: false
UseTab: Never UseTab: Never
... ...

View File

@ -277,11 +277,9 @@ void AutosaveManager::load_autosave_settings(Promise<td_api::object_ptr<td_api::
if (G()->parameters().use_message_db) { if (G()->parameters().use_message_db) {
G()->td_db()->get_sqlite_pmc()->get( G()->td_db()->get_sqlite_pmc()->get(
get_autosave_settings_database_key(), get_autosave_settings_database_key(), PromiseCreator::lambda([actor_id = actor_id(this)](string value) mutable {
PromiseCreator::lambda( send_closure(actor_id, &AutosaveManager::on_load_autosave_settings_from_database, std::move(value));
[actor_id = actor_id(this)](string value) mutable { }));
send_closure(actor_id, &AutosaveManager::on_load_autosave_settings_from_database, std::move(value));
}));
return; return;
} }

View File

@ -1621,8 +1621,7 @@ void StickersManager::init() {
load_special_sticker_set_info_from_binlog(sticker_set); load_special_sticker_set_info_from_binlog(sticker_set);
} }
dice_emojis_str_ = dice_emojis_str_ = td_->option_manager_->get_option_string("dice_emojis", "🎲\x01🎯\x01πŸ€\x01⚽\x01⚽️\x01🎰\x01🎳");
td_->option_manager_->get_option_string("dice_emojis", "🎲\x01🎯\x01πŸ€\x01⚽\x01⚽️\x01🎰\x01🎳");
dice_emojis_ = full_split(dice_emojis_str_, '\x01'); dice_emojis_ = full_split(dice_emojis_str_, '\x01');
for (auto &dice_emoji : dice_emojis_) { for (auto &dice_emoji : dice_emojis_) {
auto &animated_dice_sticker_set = add_special_sticker_set(SpecialStickerSetType::animated_dice(dice_emoji)); auto &animated_dice_sticker_set = add_special_sticker_set(SpecialStickerSetType::animated_dice(dice_emoji));

View File

@ -24,7 +24,7 @@ class As {
As(const As &new_value) = delete; As(const As &new_value) = delete;
As &operator=(const As &) = delete; As &operator=(const As &) = delete;
As(As &&) = default; As(As &&) = default;
As &operator=(As &&new_value) &&noexcept { As &operator=(As &&new_value) && noexcept {
std::memcpy(ptr_, new_value.ptr_, sizeof(T)); std::memcpy(ptr_, new_value.ptr_, sizeof(T));
return *this; return *this;
} }

View File

@ -34,7 +34,7 @@ constexpr size_t member_function_argument_count() {
// there is no std::is_trivially_copyable in libstdc++ before 5.0 // there is no std::is_trivially_copyable in libstdc++ before 5.0
#if __GLIBCXX__ #if __GLIBCXX__
#if TD_CLANG || (TD_GCC && __GNUC__ >= 5) // but clang >= 3.0 and g++ >= 5.0 supports __is_trivially_copyable #if TD_CLANG || (TD_GCC && __GNUC__ >= 5) // but clang >= 3.0 and g++ >= 5.0 supports __is_trivially_copyable
#define TD_IS_TRIVIALLY_COPYABLE(T) __is_trivially_copyable(T) #define TD_IS_TRIVIALLY_COPYABLE(T) __is_trivially_copyable(T)
#else #else
#define TD_IS_TRIVIALLY_COPYABLE(T) __has_trivial_copy(T) #define TD_IS_TRIVIALLY_COPYABLE(T) __has_trivial_copy(T)

View File

@ -1250,67 +1250,50 @@ TEST(MessageEntities, parse_html) {
check_parse_html("🏟 🏟&lt;</", "Unexpected end tag at byte offset 13"); check_parse_html("🏟 🏟&lt;</", "Unexpected end tag at byte offset 13");
check_parse_html("🏟 🏟&lt;<b></b></", "Unexpected end tag at byte offset 20"); check_parse_html("🏟 🏟&lt;<b></b></", "Unexpected end tag at byte offset 20");
check_parse_html("🏟 🏟&lt;<i>a</i ", "Unclosed end tag at byte offset 17"); check_parse_html("🏟 🏟&lt;<i>a</i ", "Unclosed end tag at byte offset 17");
check_parse_html("🏟 🏟&lt;<i>a</em >", check_parse_html("🏟 🏟&lt;<i>a</em >", "Unmatched end tag at byte offset 17, expected \"</i>\", found \"</em>\"");
"Unmatched end tag at byte offset 17, expected \"</i>\", found \"</em>\"");
check_parse_html("", "", {}); check_parse_html("", "", {});
check_parse_html("➑️ ➑️", "➑️ ➑️", {}); check_parse_html("➑️ ➑️", "➑️ ➑️", {});
check_parse_html("&ge;&lt;&gt;&amp;&quot;&laquo;&raquo;&#12345678;", "&ge;<>&\"&laquo;&raquo;&#12345678;", {}); check_parse_html("&ge;&lt;&gt;&amp;&quot;&laquo;&raquo;&#12345678;", "&ge;<>&\"&laquo;&raquo;&#12345678;", {});
check_parse_html("&Or;", "&Or;", {}); check_parse_html("&Or;", "&Or;", {});
check_parse_html("➑️ ➑️<i>➑️ ➑️</i>", "➑️ ➑️➑️ ➑️", check_parse_html("➑️ ➑️<i>➑️ ➑️</i>", "➑️ ➑️➑️ ➑️", {{td::MessageEntity::Type::Italic, 5, 5}});
{{td::MessageEntity::Type::Italic, 5, 5}}); check_parse_html("➑️ ➑️<em>➑️ ➑️</em>", "➑️ ➑️➑️ ➑️", {{td::MessageEntity::Type::Italic, 5, 5}});
check_parse_html("➑️ ➑️<em>➑️ ➑️</em>", "➑️ ➑️➑️ ➑️", check_parse_html("➑️ ➑️<b>➑️ ➑️</b>", "➑️ ➑️➑️ ➑️", {{td::MessageEntity::Type::Bold, 5, 5}});
{{td::MessageEntity::Type::Italic, 5, 5}}); check_parse_html("➑️ ➑️<strong>➑️ ➑️</strong>", "➑️ ➑️➑️ ➑️", {{td::MessageEntity::Type::Bold, 5, 5}});
check_parse_html("➑️ ➑️<b>➑️ ➑️</b>", "➑️ ➑️➑️ ➑️", check_parse_html("➑️ ➑️<u>➑️ ➑️</u>", "➑️ ➑️➑️ ➑️", {{td::MessageEntity::Type::Underline, 5, 5}});
{{td::MessageEntity::Type::Bold, 5, 5}}); check_parse_html("➑️ ➑️<ins>➑️ ➑️</ins>", "➑️ ➑️➑️ ➑️", {{td::MessageEntity::Type::Underline, 5, 5}});
check_parse_html("➑️ ➑️<strong>➑️ ➑️</strong>", "➑️ ➑️➑️ ➑️", check_parse_html("➑️ ➑️<s>➑️ ➑️</s>", "➑️ ➑️➑️ ➑️", {{td::MessageEntity::Type::Strikethrough, 5, 5}});
{{td::MessageEntity::Type::Bold, 5, 5}}); check_parse_html("➑️ ➑️<strike>➑️ ➑️</strike>", "➑️ ➑️➑️ ➑️", {{td::MessageEntity::Type::Strikethrough, 5, 5}});
check_parse_html("➑️ ➑️<u>➑️ ➑️</u>", "➑️ ➑️➑️ ➑️", check_parse_html("➑️ ➑️<del>➑️ ➑️</del>", "➑️ ➑️➑️ ➑️", {{td::MessageEntity::Type::Strikethrough, 5, 5}});
{{td::MessageEntity::Type::Underline, 5, 5}});
check_parse_html("➑️ ➑️<ins>➑️ ➑️</ins>", "➑️ ➑️➑️ ➑️",
{{td::MessageEntity::Type::Underline, 5, 5}});
check_parse_html("➑️ ➑️<s>➑️ ➑️</s>", "➑️ ➑️➑️ ➑️",
{{td::MessageEntity::Type::Strikethrough, 5, 5}});
check_parse_html("➑️ ➑️<strike>➑️ ➑️</strike>", "➑️ ➑️➑️ ➑️",
{{td::MessageEntity::Type::Strikethrough, 5, 5}});
check_parse_html("➑️ ➑️<del>➑️ ➑️</del>", "➑️ ➑️➑️ ➑️",
{{td::MessageEntity::Type::Strikethrough, 5, 5}});
check_parse_html("➑️ ➑️<i>➑️ ➑️</i><b>➑️ ➑️</b>", "➑️ ➑️➑️ ➑️➑️ ➑️", check_parse_html("➑️ ➑️<i>➑️ ➑️</i><b>➑️ ➑️</b>", "➑️ ➑️➑️ ➑️➑️ ➑️",
{{td::MessageEntity::Type::Italic, 5, 5}, {td::MessageEntity::Type::Bold, 10, 5}}); {{td::MessageEntity::Type::Italic, 5, 5}, {td::MessageEntity::Type::Bold, 10, 5}});
check_parse_html("🏟 🏟<i>🏟 &lt🏟</i>", "🏟 🏟🏟 <🏟", {{td::MessageEntity::Type::Italic, 5, 6}}); check_parse_html("🏟 🏟<i>🏟 &lt🏟</i>", "🏟 🏟🏟 <🏟", {{td::MessageEntity::Type::Italic, 5, 6}});
check_parse_html("🏟 🏟<i>🏟 &gt;<b aba = caba>&lt🏟</b></i>", "🏟 🏟🏟 ><🏟", check_parse_html("🏟 🏟<i>🏟 &gt;<b aba = caba>&lt🏟</b></i>", "🏟 🏟🏟 ><🏟",
{{td::MessageEntity::Type::Italic, 5, 7}, {td::MessageEntity::Type::Bold, 9, 3}}); {{td::MessageEntity::Type::Italic, 5, 7}, {td::MessageEntity::Type::Bold, 9, 3}});
check_parse_html("🏟 🏟&lt;<i aba = 190azAz-. >a</i>", "🏟 🏟<a", check_parse_html("🏟 🏟&lt;<i aba = 190azAz-. >a</i>", "🏟 🏟<a", {{td::MessageEntity::Type::Italic, 6, 1}});
{{td::MessageEntity::Type::Italic, 6, 1}}); check_parse_html("🏟 🏟&lt;<i aba = 190azAz-.>a</i>", "🏟 🏟<a", {{td::MessageEntity::Type::Italic, 6, 1}});
check_parse_html("🏟 🏟&lt;<i aba = 190azAz-.>a</i>", "🏟 🏟<a",
{{td::MessageEntity::Type::Italic, 6, 1}});
check_parse_html("🏟 🏟&lt;<i aba = \"&lt;&gt;&quot;\">a</i>", "🏟 🏟<a", check_parse_html("🏟 🏟&lt;<i aba = \"&lt;&gt;&quot;\">a</i>", "🏟 🏟<a",
{{td::MessageEntity::Type::Italic, 6, 1}}); {{td::MessageEntity::Type::Italic, 6, 1}});
check_parse_html("🏟 🏟&lt;<i aba = '&lt;&gt;&quot;'>a</i>", "🏟 🏟<a", check_parse_html("🏟 🏟&lt;<i aba = '&lt;&gt;&quot;'>a</i>", "🏟 🏟<a",
{{td::MessageEntity::Type::Italic, 6, 1}}); {{td::MessageEntity::Type::Italic, 6, 1}});
check_parse_html("🏟 🏟&lt;<i aba = '&lt;&gt;&quot;'>a</>", "🏟 🏟<a", check_parse_html("🏟 🏟&lt;<i aba = '&lt;&gt;&quot;'>a</>", "🏟 🏟<a",
{{td::MessageEntity::Type::Italic, 6, 1}}); {{td::MessageEntity::Type::Italic, 6, 1}});
check_parse_html("🏟 🏟&lt;<i>🏟 🏟&lt;</>", "🏟 🏟<🏟 🏟<", check_parse_html("🏟 🏟&lt;<i>🏟 🏟&lt;</>", "🏟 🏟<🏟 🏟<", {{td::MessageEntity::Type::Italic, 6, 6}});
{{td::MessageEntity::Type::Italic, 6, 6}});
check_parse_html("🏟 🏟&lt;<i>a</ >", "🏟 🏟<a", {{td::MessageEntity::Type::Italic, 6, 1}}); check_parse_html("🏟 🏟&lt;<i>a</ >", "🏟 🏟<a", {{td::MessageEntity::Type::Italic, 6, 1}});
check_parse_html("🏟 🏟&lt;<i>a</i >", "🏟 🏟<a", {{td::MessageEntity::Type::Italic, 6, 1}}); check_parse_html("🏟 🏟&lt;<i>a</i >", "🏟 🏟<a", {{td::MessageEntity::Type::Italic, 6, 1}});
check_parse_html("🏟 🏟&lt;<b></b>", "🏟 🏟<", {}); check_parse_html("🏟 🏟&lt;<b></b>", "🏟 🏟<", {});
check_parse_html("<i>\t</i>", "\t", {{td::MessageEntity::Type::Italic, 0, 1}}); check_parse_html("<i>\t</i>", "\t", {{td::MessageEntity::Type::Italic, 0, 1}});
check_parse_html("<i>\r</i>", "\r", {{td::MessageEntity::Type::Italic, 0, 1}}); check_parse_html("<i>\r</i>", "\r", {{td::MessageEntity::Type::Italic, 0, 1}});
check_parse_html("<i>\n</i>", "\n", {{td::MessageEntity::Type::Italic, 0, 1}}); check_parse_html("<i>\n</i>", "\n", {{td::MessageEntity::Type::Italic, 0, 1}});
check_parse_html("➑️ ➑️<span class = \"tg-spoiler\">➑️ ➑️</span><b>➑️ ➑️</b>", check_parse_html("➑️ ➑️<span class = \"tg-spoiler\">➑️ ➑️</span><b>➑️ ➑️</b>", "➑️ ➑️➑️ ➑️➑️ ➑️",
"➑️ ➑️➑️ ➑️➑️ ➑️",
{{td::MessageEntity::Type::Spoiler, 5, 5}, {td::MessageEntity::Type::Bold, 10, 5}}); {{td::MessageEntity::Type::Spoiler, 5, 5}, {td::MessageEntity::Type::Bold, 10, 5}});
check_parse_html("🏟 🏟<span class=\"tg-spoiler\">🏟 &lt🏟</span>", "🏟 🏟🏟 <🏟", check_parse_html("🏟 🏟<span class=\"tg-spoiler\">🏟 &lt🏟</span>", "🏟 🏟🏟 <🏟",
{{td::MessageEntity::Type::Spoiler, 5, 6}}); {{td::MessageEntity::Type::Spoiler, 5, 6}});
check_parse_html("🏟 🏟<span class=\"tg-spoiler\">🏟 &gt;<b aba = caba>&lt🏟</b></span>", check_parse_html("🏟 🏟<span class=\"tg-spoiler\">🏟 &gt;<b aba = caba>&lt🏟</b></span>", "🏟 🏟🏟 ><🏟",
"🏟 🏟🏟 ><🏟",
{{td::MessageEntity::Type::Spoiler, 5, 7}, {td::MessageEntity::Type::Bold, 9, 3}}); {{td::MessageEntity::Type::Spoiler, 5, 7}, {td::MessageEntity::Type::Bold, 9, 3}});
check_parse_html("➑️ ➑️<tg-spoiler>➑️ ➑️</tg-spoiler><b>➑️ ➑️</b>", check_parse_html("➑️ ➑️<tg-spoiler>➑️ ➑️</tg-spoiler><b>➑️ ➑️</b>", "➑️ ➑️➑️ ➑️➑️ ➑️",
"➑️ ➑️➑️ ➑️➑️ ➑️",
{{td::MessageEntity::Type::Spoiler, 5, 5}, {td::MessageEntity::Type::Bold, 10, 5}}); {{td::MessageEntity::Type::Spoiler, 5, 5}, {td::MessageEntity::Type::Bold, 10, 5}});
check_parse_html("🏟 🏟<tg-spoiler>🏟 &lt🏟</tg-spoiler>", "🏟 🏟🏟 <🏟", check_parse_html("🏟 🏟<tg-spoiler>🏟 &lt🏟</tg-spoiler>", "🏟 🏟🏟 <🏟", {{td::MessageEntity::Type::Spoiler, 5, 6}});
{{td::MessageEntity::Type::Spoiler, 5, 6}});
check_parse_html("🏟 🏟<tg-spoiler>🏟 &gt;<b aba = caba>&lt🏟</b></tg-spoiler>", "🏟 🏟🏟 ><🏟", check_parse_html("🏟 🏟<tg-spoiler>🏟 &gt;<b aba = caba>&lt🏟</b></tg-spoiler>", "🏟 🏟🏟 ><🏟",
{{td::MessageEntity::Type::Spoiler, 5, 7}, {td::MessageEntity::Type::Bold, 9, 3}}); {{td::MessageEntity::Type::Spoiler, 5, 7}, {td::MessageEntity::Type::Bold, 9, 3}});
check_parse_html("<a href=telegram.org>\t</a>", "\t", check_parse_html("<a href=telegram.org>\t</a>", "\t",
@ -1344,10 +1327,8 @@ TEST(MessageEntities, parse_html) {
{{td::MessageEntity::Type::TextUrl, 0, 12, "http://telegram.org/"}}); {{td::MessageEntity::Type::TextUrl, 0, 12, "http://telegram.org/"}});
check_parse_html("<a>https://telegram.org/asdsa?asdasdwe#12e3we</a>", "https://telegram.org/asdsa?asdasdwe#12e3we", check_parse_html("<a>https://telegram.org/asdsa?asdasdwe#12e3we</a>", "https://telegram.org/asdsa?asdasdwe#12e3we",
{{td::MessageEntity::Type::TextUrl, 0, 42, "https://telegram.org/asdsa?asdasdwe#12e3we"}}); {{td::MessageEntity::Type::TextUrl, 0, 42, "https://telegram.org/asdsa?asdasdwe#12e3we"}});
check_parse_html("🏟 🏟&lt;<pre >🏟 🏟&lt;</>", "🏟 🏟<🏟 🏟<", check_parse_html("🏟 🏟&lt;<pre >🏟 🏟&lt;</>", "🏟 🏟<🏟 🏟<", {{td::MessageEntity::Type::Pre, 6, 6}});
{{td::MessageEntity::Type::Pre, 6, 6}}); check_parse_html("🏟 🏟&lt;<code >🏟 🏟&lt;</>", "🏟 🏟<🏟 🏟<", {{td::MessageEntity::Type::Code, 6, 6}});
check_parse_html("🏟 🏟&lt;<code >🏟 🏟&lt;</>", "🏟 🏟<🏟 🏟<",
{{td::MessageEntity::Type::Code, 6, 6}});
check_parse_html("🏟 🏟&lt;<pre><code>🏟 🏟&lt;</code></>", "🏟 🏟<🏟 🏟<", check_parse_html("🏟 🏟&lt;<pre><code>🏟 🏟&lt;</code></>", "🏟 🏟<🏟 🏟<",
{{td::MessageEntity::Type::Pre, 6, 6}, {td::MessageEntity::Type::Code, 6, 6}}); {{td::MessageEntity::Type::Pre, 6, 6}, {td::MessageEntity::Type::Code, 6, 6}});
check_parse_html("🏟 🏟&lt;<pre><code class=\"language-\">🏟 🏟&lt;</code></>", "🏟 🏟<🏟 🏟<", check_parse_html("🏟 🏟&lt;<pre><code class=\"language-\">🏟 🏟&lt;</code></>", "🏟 🏟<🏟 🏟<",
@ -1360,8 +1341,7 @@ TEST(MessageEntities, parse_html) {
{{td::MessageEntity::Type::Pre, 6, 7}, {td::MessageEntity::Type::Code, 6, 6}}); {{td::MessageEntity::Type::Pre, 6, 7}, {td::MessageEntity::Type::Code, 6, 6}});
check_parse_html("🏟 🏟&lt;<pre> <code class=\"language-fift\">🏟 🏟&lt;</></>", "🏟 🏟< 🏟 🏟<", check_parse_html("🏟 🏟&lt;<pre> <code class=\"language-fift\">🏟 🏟&lt;</></>", "🏟 🏟< 🏟 🏟<",
{{td::MessageEntity::Type::Pre, 6, 7}, {td::MessageEntity::Type::Code, 7, 6}}); {{td::MessageEntity::Type::Pre, 6, 7}, {td::MessageEntity::Type::Code, 7, 6}});
check_parse_html("➑️ ➑️<tg-emoji emoji-id = \"12345\">➑️ ➑️</tg-emoji><b>➑️ ➑️</b>", check_parse_html("➑️ ➑️<tg-emoji emoji-id = \"12345\">➑️ ➑️</tg-emoji><b>➑️ ➑️</b>", "➑️ ➑️➑️ ➑️➑️ ➑️",
"➑️ ➑️➑️ ➑️➑️ ➑️",
{{td::MessageEntity::Type::CustomEmoji, 5, 5, td::CustomEmojiId(static_cast<td::int64>(12345))}, {{td::MessageEntity::Type::CustomEmoji, 5, 5, td::CustomEmojiId(static_cast<td::int64>(12345))},
{td::MessageEntity::Type::Bold, 10, 5}}); {td::MessageEntity::Type::Bold, 10, 5}});
check_parse_html("🏟 🏟<tg-emoji emoji-id=\"54321\">🏟 &lt🏟</tg-emoji>", "🏟 🏟🏟 <🏟", check_parse_html("🏟 🏟<tg-emoji emoji-id=\"54321\">🏟 &lt🏟</tg-emoji>", "🏟 🏟🏟 <🏟",
@ -1444,8 +1424,7 @@ TEST(MessageEntities, parse_markdown) {
check_parse_markdown("🏟 🏟_abac \\* asd _", "🏟 🏟abac * asd ", {{td::MessageEntity::Type::Italic, 5, 11}}); check_parse_markdown("🏟 🏟_abac \\* asd _", "🏟 🏟abac * asd ", {{td::MessageEntity::Type::Italic, 5, 11}});
check_parse_markdown("🏟 \\.🏟_🏟\\. 🏟_", "🏟 .🏟🏟. 🏟", {{td::MessageEntity::Type::Italic, 6, 6}}); check_parse_markdown("🏟 \\.🏟_🏟\\. 🏟_", "🏟 .🏟🏟. 🏟", {{td::MessageEntity::Type::Italic, 6, 6}});
check_parse_markdown("\\\\\\a\\b\\c\\d\\e\\f\\1\\2\\3\\4\\➑️\\", "\\abcdef1234\\➑️\\", {}); check_parse_markdown("\\\\\\a\\b\\c\\d\\e\\f\\1\\2\\3\\4\\➑️\\", "\\abcdef1234\\➑️\\", {});
check_parse_markdown("➑️ ➑️_➑️ ➑️_", "➑️ ➑️➑️ ➑️", check_parse_markdown("➑️ ➑️_➑️ ➑️_", "➑️ ➑️➑️ ➑️", {{td::MessageEntity::Type::Italic, 5, 5}});
{{td::MessageEntity::Type::Italic, 5, 5}});
check_parse_markdown("➑️ ➑️_➑️ ➑️_*➑️ ➑️*", "➑️ ➑️➑️ ➑️➑️ ➑️", check_parse_markdown("➑️ ➑️_➑️ ➑️_*➑️ ➑️*", "➑️ ➑️➑️ ➑️➑️ ➑️",
{{td::MessageEntity::Type::Italic, 5, 5}, {td::MessageEntity::Type::Bold, 10, 5}}); {{td::MessageEntity::Type::Italic, 5, 5}, {td::MessageEntity::Type::Bold, 10, 5}});
check_parse_markdown("🏟 🏟_🏟 \\.🏟_", "🏟 🏟🏟 .🏟", {{td::MessageEntity::Type::Italic, 5, 6}}); check_parse_markdown("🏟 🏟_🏟 \\.🏟_", "🏟 🏟🏟 .🏟", {{td::MessageEntity::Type::Italic, 5, 6}});
@ -1458,22 +1437,14 @@ TEST(MessageEntities, parse_markdown) {
check_parse_markdown("🏟 🏟__🏟 _🏟_\\___", "🏟 🏟🏟 🏟_", check_parse_markdown("🏟 🏟__🏟 _🏟_\\___", "🏟 🏟🏟 🏟_",
{{td::MessageEntity::Type::Underline, 5, 6}, {td::MessageEntity::Type::Italic, 8, 2}}); {{td::MessageEntity::Type::Underline, 5, 6}, {td::MessageEntity::Type::Italic, 8, 2}});
check_parse_markdown("🏟 🏟`🏟 🏟```", "🏟 🏟🏟 🏟", {{td::MessageEntity::Type::Code, 5, 5}}); check_parse_markdown("🏟 🏟`🏟 🏟```", "🏟 🏟🏟 🏟", {{td::MessageEntity::Type::Code, 5, 5}});
check_parse_markdown("🏟 🏟```🏟 🏟```", "🏟 🏟 🏟", check_parse_markdown("🏟 🏟```🏟 🏟```", "🏟 🏟 🏟", {{td::MessageEntity::Type::PreCode, 5, 3, "🏟"}});
{{td::MessageEntity::Type::PreCode, 5, 3, "🏟"}}); check_parse_markdown("🏟 🏟```🏟\n🏟```", "🏟 🏟🏟", {{td::MessageEntity::Type::PreCode, 5, 2, "🏟"}});
check_parse_markdown("🏟 🏟```🏟\n🏟```", "🏟 🏟🏟", check_parse_markdown("🏟 🏟```🏟\r🏟```", "🏟 🏟🏟", {{td::MessageEntity::Type::PreCode, 5, 2, "🏟"}});
{{td::MessageEntity::Type::PreCode, 5, 2, "🏟"}}); check_parse_markdown("🏟 🏟```🏟\n\r🏟```", "🏟 🏟🏟", {{td::MessageEntity::Type::PreCode, 5, 2, "🏟"}});
check_parse_markdown("🏟 🏟```🏟\r🏟```", "🏟 🏟🏟", check_parse_markdown("🏟 🏟```🏟\r\n🏟```", "🏟 🏟🏟", {{td::MessageEntity::Type::PreCode, 5, 2, "🏟"}});
{{td::MessageEntity::Type::PreCode, 5, 2, "🏟"}}); check_parse_markdown("🏟 🏟```🏟\n\n🏟```", "🏟 🏟\n🏟", {{td::MessageEntity::Type::PreCode, 5, 3, "🏟"}});
check_parse_markdown("🏟 🏟```🏟\n\r🏟```", "🏟 🏟🏟", check_parse_markdown("🏟 🏟```🏟\r\r🏟```", "🏟 🏟\r🏟", {{td::MessageEntity::Type::PreCode, 5, 3, "🏟"}});
{{td::MessageEntity::Type::PreCode, 5, 2, "🏟"}}); check_parse_markdown("🏟 🏟```🏟 \\\\\\`🏟```", "🏟 🏟 \\`🏟", {{td::MessageEntity::Type::PreCode, 5, 5, "🏟"}});
check_parse_markdown("🏟 🏟```🏟\r\n🏟```", "🏟 🏟🏟",
{{td::MessageEntity::Type::PreCode, 5, 2, "🏟"}});
check_parse_markdown("🏟 🏟```🏟\n\n🏟```", "🏟 🏟\n🏟",
{{td::MessageEntity::Type::PreCode, 5, 3, "🏟"}});
check_parse_markdown("🏟 🏟```🏟\r\r🏟```", "🏟 🏟\r🏟",
{{td::MessageEntity::Type::PreCode, 5, 3, "🏟"}});
check_parse_markdown("🏟 🏟```🏟 \\\\\\`🏟```", "🏟 🏟 \\`🏟",
{{td::MessageEntity::Type::PreCode, 5, 5, "🏟"}});
check_parse_markdown("🏟 🏟**", "🏟 🏟", {}); check_parse_markdown("🏟 🏟**", "🏟 🏟", {});
check_parse_markdown("||test||", "test", {{td::MessageEntity::Type::Spoiler, 0, 4}}); check_parse_markdown("||test||", "test", {{td::MessageEntity::Type::Spoiler, 0, 4}});
check_parse_markdown("🏟 🏟``", "🏟 🏟", {}); check_parse_markdown("🏟 🏟``", "🏟 🏟", {});
@ -1533,19 +1504,18 @@ TEST(MessageEntities, parse_markdown_v3) {
check_parse_markdown_v3("🏟````🏟``🏟`aba🏟```c🏟`aba🏟 daba🏟```c🏟`aba🏟```🏟 `🏟``🏟```", check_parse_markdown_v3("🏟````🏟``🏟`aba🏟```c🏟`aba🏟 daba🏟```c🏟`aba🏟```🏟 `🏟``🏟```",
"🏟````🏟``🏟aba🏟```c🏟aba🏟 daba🏟c🏟`aba🏟🏟 `🏟``🏟```", "🏟````🏟``🏟aba🏟```c🏟aba🏟 daba🏟c🏟`aba🏟🏟 `🏟``🏟```",
{{td::MessageEntity::Type::Code, 12, 11}, {td::MessageEntity::Type::Pre, 35, 9}}); {{td::MessageEntity::Type::Code, 12, 11}, {td::MessageEntity::Type::Pre, 35, 9}});
check_parse_markdown_v3( check_parse_markdown_v3("🏟````🏟``🏟`aba🏟```c🏟`aba🏟 daba🏟```c🏟`aba🏟🏟```🏟 `🏟``🏟```",
"🏟````🏟``🏟`aba🏟```c🏟`aba🏟 daba🏟```c🏟`aba🏟🏟```🏟 `🏟``🏟```", {{td::MessageEntity::Type::Italic, 12, 1},
{{td::MessageEntity::Type::Italic, 12, 1}, {td::MessageEntity::Type::Italic, 44, 1},
{td::MessageEntity::Type::Italic, 44, 1}, {td::MessageEntity::Type::Bold, 45, 1},
{td::MessageEntity::Type::Bold, 45, 1}, {td::MessageEntity::Type::Bold, 49, 2}},
{td::MessageEntity::Type::Bold, 49, 2}}, "🏟````🏟``🏟`aba🏟c🏟`aba🏟 daba🏟c🏟`aba🏟🏟🏟 `🏟``🏟",
"🏟````🏟``🏟`aba🏟c🏟`aba🏟 daba🏟c🏟`aba🏟🏟🏟 `🏟``🏟", {{td::MessageEntity::Type::Italic, 12, 1},
{{td::MessageEntity::Type::Italic, 12, 1}, {td::MessageEntity::Type::Pre, 18, 16},
{td::MessageEntity::Type::Pre, 18, 16}, {td::MessageEntity::Type::Italic, 38, 1},
{td::MessageEntity::Type::Italic, 38, 1}, {td::MessageEntity::Type::Bold, 39, 1},
{td::MessageEntity::Type::Bold, 39, 1}, {td::MessageEntity::Type::Bold, 43, 2},
{td::MessageEntity::Type::Bold, 43, 2}, {td::MessageEntity::Type::Pre, 45, 10}});
{td::MessageEntity::Type::Pre, 45, 10}});
check_parse_markdown_v3("` `", " ", {{td::MessageEntity::Type::Code, 0, 1}}); check_parse_markdown_v3("` `", " ", {{td::MessageEntity::Type::Code, 0, 1}});
check_parse_markdown_v3("`\n`", "\n", {{td::MessageEntity::Type::Code, 0, 1}}); check_parse_markdown_v3("`\n`", "\n", {{td::MessageEntity::Type::Code, 0, 1}});
check_parse_markdown_v3("` `a", " a", {{td::MessageEntity::Type::Code, 0, 1}}, true); check_parse_markdown_v3("` `a", " a", {{td::MessageEntity::Type::Code, 0, 1}}, true);