Handle Windows line endings and verify empty code blocks
This commit is contained in:
1 parent
77186c4392
commit
c19750a800
4 files changed
+27
-16
No files matched your search
@@ -24,6 +24,7 @@ private slots:
|
||||
QTest::newRow("code") << "before\n```cpp\n int x;\n\t/* **literal** */\n\n```\nafter"
|
||||
<< "before\n int x;\n\t/* **literal** */\n\nafter" << 0 << 1;
|
||||
QTest::newRow("empty-code") << "```\n```" << "" << 0 << 1;
|
||||
QTest::newRow("windows-newlines") << "```cpp\r\nint x;\r\n```" << "int x;" << 0 << 1;
|
||||
QTest::newRow("blank-code") << "```\n\n\n```" << "\n" << 0 << 1;
|
||||
QTest::newRow("two-blocks") << "```c\nint x;\n```\n**bold**\n```python\npass\n```"
|
||||
<< "int x;\nbold\npass" << 1 << 2;
|
||||
@@ -74,6 +75,11 @@ private slots:
|
||||
const auto unknown = formattedMessageText(index); QVERIFY(unknown); QVERIFY(unknown->lightSyntax.isEmpty());
|
||||
model.setData(index, "```\nint x;\n```", MsgTextRole);
|
||||
const auto plainCode = formattedMessageText(index); QVERIFY(plainCode); QVERIFY(plainCode->lightSyntax.isEmpty());
|
||||
model.setData(index, "```\n```", MsgTextRole);
|
||||
const auto emptyCode = formattedMessageText(index); QVERIFY(emptyCode);
|
||||
QTextLayout emptyLayout; emptyLayout.setFont(QApplication::font());
|
||||
QVERIFY(layoutFormattedMessage(emptyLayout, *emptyCode, 200, false) > 0);
|
||||
QCOMPARE(emptyLayout.lineCount(), 1); QVERIFY(emptyCode->isCode(emptyLayout.lineAt(0).textStart()));
|
||||
model.setData(index, "**invitation**", MsgTextRole); model.setData(index, "utun://abc", MsgInviteLinkRole);
|
||||
QVERIFY(!formattedMessageText(index));
|
||||
model.setData(index, QString(), MsgInviteLinkRole); model.setData(index, "poll", MsgContentTypeRole);
|
||||
|
||||
Reference in new issue
Block a user