1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681
|
/*
This file is part of the Grantlee template system.
Copyright (c) 2008 Stephen Kelly <steveire@gmail.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either version
2.1 of the Licence, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include <QtCore/QRegularExpression>
#include <QtCore>
#include <QtGui/QTextCursor>
#include <QtGui/QTextDocument>
#include <QtGui/QTextLine>
#include <QtTest/QtTest>
#include <QtTest/qtestevent.h>
#include "coverageobject.h"
#include "markupdirector.h"
#include "plaintextmarkupbuilder.h"
#include "testutils.h"
#include "texthtmlbuilder.h"
#include <memory>
using namespace Grantlee;
class TestPlainMarkupOutput : public CoverageObject
{
Q_OBJECT
private Q_SLOTS:
// Test paragraph contents:
void testSingleFormat();
void testDoubleFormat();
void testDoubleStartDifferentFinish();
void testDoubleStartDifferentFinishReverseOrder();
void testDifferentStartDoubleFinish();
void testDifferentStartDoubleFinishReverseOrder();
void testOverlap();
void testAnchor();
void testAnchorWithFormattedContent();
void testAdjacentAnchors();
void testNestedFormatting();
void testSpan();
void testDoubleSpan();
void testSpanNesting();
void testEdgeCaseLeft();
void testEdgeCaseRight();
void testImage();
void testImageResized();
void testEachFormatTagSingly();
void testHorizontalRule();
void testNewlines();
void testEmptyParagraphs();
void testNewlinesThroughQTextCursor();
void testBrInsideParagraph();
void testLongDocument();
void testNestedList();
};
void TestPlainMarkupOutput::testSingleFormat()
{
QTextDocument doc;
// One format
doc.setHtml(QStringLiteral("This <b>text</b> is bold."));
PlainTextMarkupBuilder hb;
MarkupDirector md(&hb);
md.processDocument(&doc);
auto result = hb.getResult();
QRegularExpression regex(QStringLiteral("^This \\*text\\* is bold.\\n$"));
QVERIFY(regex.match(result).hasMatch());
}
void TestPlainMarkupOutput::testDoubleFormat()
{
QTextDocument doc;
// One format
doc.setHtml(QStringLiteral("Some <b><i>formatted</i></b> text."));
PlainTextMarkupBuilder hb;
MarkupDirector md(&hb);
md.processDocument(&doc);
auto result = hb.getResult();
QRegularExpression regex(
QStringLiteral("^Some (\\*/|/\\*)formatted(\\*/|/\\*) text.\\n$"));
QVERIFY(regex.match(result).hasMatch());
}
void TestPlainMarkupOutput::testAnchor()
{
QTextDocument doc;
doc.setHtml(
QStringLiteral("A <a href=\"http://www.kde.org\">link</a> to KDE."));
PlainTextMarkupBuilder hb;
MarkupDirector md(&hb);
md.processDocument(&doc);
auto result = hb.getResult();
QRegularExpression regex(QStringLiteral(
"^A link\\[1\\] to KDE.\\n\\n--------\\n\\[1\\] http://www.kde.org\\n$"));
regex.match(result).hasMatch();
QVERIFY(regex.match(result).hasMatch());
}
void TestPlainMarkupOutput::testAnchorWithFormattedContent()
{
QTextDocument doc;
doc.setHtml(QStringLiteral(
"A <a href=\"http://www.kde.org\"><b>formatted</b> link</a> to KDE."));
PlainTextMarkupBuilder hb;
MarkupDirector md(&hb);
md.processDocument(&doc);
auto result = hb.getResult();
QRegularExpression regex(
QStringLiteral("^A \\*formatted\\* link\\[1\\] to "
"KDE.\\n\\n--------\\n\\[1\\] http://www.kde.org\\n$"));
QVERIFY(regex.match(result).hasMatch());
}
void TestPlainMarkupOutput::testAdjacentAnchors()
{
QTextDocument doc;
doc.setHtml(
QStringLiteral("Two <a href=\"http://www.kde.org\">links</a><a "
"href=\"http://www.google.com\">next</a> to eachother."));
PlainTextMarkupBuilder hb;
MarkupDirector md(&hb);
md.processDocument(&doc);
auto result = hb.getResult();
QRegularExpression regex(QStringLiteral(
"^Two links\\[1\\]next\\[2\\] to eachother.\\n\\n--------\\n\\[1\\] "
"http://www.kde.org\\n\\[2\\] http://www.google.com\\n$"));
QVERIFY(regex.match(result).hasMatch());
}
void TestPlainMarkupOutput::testNestedFormatting()
{
QTextDocument doc;
doc.setHtml(QStringLiteral("This <b>text is <i>italic</i> and</b> bold."));
PlainTextMarkupBuilder hb;
MarkupDirector md(&hb);
md.processDocument(&doc);
auto result = hb.getResult();
QRegularExpression regex(
QStringLiteral("^This \\*text is /italic/ and\\* bold.\\n$"));
QVERIFY(regex.match(result).hasMatch());
}
void TestPlainMarkupOutput::testSpan()
{
QTextDocument doc;
doc.setHtml(QStringLiteral(
"Some <span style=\"color:#ff0000;\">formatted</span> text."));
PlainTextMarkupBuilder hb;
MarkupDirector md(&hb);
md.processDocument(&doc);
auto result = hb.getResult();
auto regex = QRegularExpression(QStringLiteral("^Some formatted text.\\n$"));
QVERIFY(regex.match(result).hasMatch());
}
void TestPlainMarkupOutput::testDoubleSpan()
{
QTextDocument doc;
doc.setHtml(QStringLiteral("Some <span "
"style=\"color:#ff0000;background-color:#00ff00;"
"\">formatted</span> text."));
PlainTextMarkupBuilder hb;
MarkupDirector md(&hb);
md.processDocument(&doc);
auto result = hb.getResult();
auto regex = QRegularExpression(QStringLiteral("^Some formatted text.\\n$"));
QVERIFY(regex.match(result).hasMatch());
}
void TestPlainMarkupOutput::testSpanNesting()
{
QTextDocument doc;
doc.setHtml(QStringLiteral(
"Paragraph <span style=\"background-color:#00ff00;\">with some <span "
"style=\"color:#ff0000;\">formatted</span> nested</span> text."));
PlainTextMarkupBuilder hb;
MarkupDirector md(&hb);
md.processDocument(&doc);
auto result = hb.getResult();
auto regex = QRegularExpression(
QStringLiteral("^Paragraph with some formatted nested text.\\n$"));
QVERIFY(regex.match(result).hasMatch());
}
void TestPlainMarkupOutput::testDoubleStartDifferentFinish()
{
QTextDocument doc;
doc.setHtml(
QStringLiteral("Paragraph <i><b>with</b> some formatted</i> text."));
PlainTextMarkupBuilder hb;
MarkupDirector md(&hb);
md.processDocument(&doc);
auto result = hb.getResult();
auto regex = QRegularExpression(
QStringLiteral("^Paragraph /\\*with\\* some formatted/ text.\\n$"));
QVERIFY(regex.match(result).hasMatch());
}
void TestPlainMarkupOutput::testDoubleStartDifferentFinishReverseOrder()
{
QTextDocument doc;
doc.setHtml(
QStringLiteral("Paragraph <b><i>with</i> some formatted</b> text."));
PlainTextMarkupBuilder hb;
MarkupDirector md(&hb);
md.processDocument(&doc);
auto result = hb.getResult();
auto regex = QRegularExpression(
QStringLiteral("^Paragraph \\*/with/ some formatted\\* text.\\n$"));
QVERIFY(regex.match(result).hasMatch());
}
void TestPlainMarkupOutput::testDifferentStartDoubleFinish()
{
QTextDocument doc;
doc.setHtml(
QStringLiteral("Paragraph <i>with some <b>formatted<b></i> text."));
PlainTextMarkupBuilder hb;
MarkupDirector md(&hb);
md.processDocument(&doc);
auto result = hb.getResult();
auto regex = QRegularExpression(
QStringLiteral("^Paragraph /with some \\*formatted\\*/ text.\\n$"));
QVERIFY(regex.match(result).hasMatch());
}
void TestPlainMarkupOutput::testDifferentStartDoubleFinishReverseOrder()
{
QTextDocument doc;
doc.setHtml(
QStringLiteral("Paragraph <b>with some <i>formatted</i></b> text."));
PlainTextMarkupBuilder hb;
MarkupDirector md(&hb);
md.processDocument(&doc);
auto result = hb.getResult();
auto regex = QRegularExpression(
QStringLiteral("^Paragraph \\*with some /formatted/\\* text.\\n$"));
QVERIFY(regex.match(result).hasMatch());
}
void TestPlainMarkupOutput::testOverlap()
{
QTextDocument doc;
doc.setHtml(QStringLiteral(
"Paragraph <b>with <i>some</i></b><i> formatted</i> text."));
PlainTextMarkupBuilder hb;
MarkupDirector md(&hb);
md.processDocument(&doc);
auto result = hb.getResult();
auto regex = QRegularExpression(
QStringLiteral("^Paragraph \\*with /some/\\*/ formatted/ text.\\n$"));
QVERIFY(regex.match(result).hasMatch());
}
void TestPlainMarkupOutput::testEdgeCaseLeft()
{
QTextDocument doc;
doc.setHtml(QStringLiteral("Paragraph <b>with some formatted text.</b>"));
PlainTextMarkupBuilder hb;
MarkupDirector md(&hb);
md.processDocument(&doc);
auto result = hb.getResult();
auto regex = QRegularExpression(
QStringLiteral("^Paragraph \\*with some formatted text.\\*\\n$"));
QVERIFY(regex.match(result).hasMatch());
}
void TestPlainMarkupOutput::testEdgeCaseRight()
{
QTextDocument doc;
doc.setHtml(QStringLiteral("<b>Paragraph with some formatted</b> text."));
PlainTextMarkupBuilder hb;
MarkupDirector md(&hb);
md.processDocument(&doc);
auto result = hb.getResult();
auto regex = QRegularExpression(
QStringLiteral("^\\*Paragraph with some formatted\\* text.\\n$"));
QVERIFY(regex.match(result).hasMatch());
}
void TestPlainMarkupOutput::testImage()
{
QTextDocument doc;
doc.setHtml(QStringLiteral("Paragraph with an inline <img "
"src=\"http://kde.org/img/kde41.png\" /> image."));
PlainTextMarkupBuilder hb;
MarkupDirector md(&hb);
md.processDocument(&doc);
auto result = hb.getResult();
auto regex = QRegularExpression(QStringLiteral(
"^Paragraph with an inline \\[1\\] image.\\n\\n--------\\n\\[1\\] "
"http://kde.org/img/kde41.png\\n$"));
QVERIFY(regex.match(result).hasMatch());
}
void TestPlainMarkupOutput::testImageResized()
{
QString result;
QRegularExpression regex;
std::unique_ptr<PlainTextMarkupBuilder> hb;
std::unique_ptr<MarkupDirector> md;
QTextDocument doc;
// width
doc.setHtml(QStringLiteral(
"Paragraph with an inline <img src=\"http://kde.org/img/kde41.png\" "
"width=\"10\" /> image."));
hb = testMakeUnique<PlainTextMarkupBuilder>();
md = testMakeUnique<MarkupDirector>(hb.get());
md->processDocument(&doc);
result = hb->getResult();
regex = QRegularExpression(QStringLiteral(
"^Paragraph with an inline \\[1\\] image.\\n\\n--------\\n\\[1\\] "
"http://kde.org/img/kde41.png\\n$"));
QVERIFY(regex.match(result).hasMatch());
// height
doc.setHtml(QStringLiteral(
"Paragraph with an inline <img src=\"http://kde.org/img/kde41.png\" "
"height=\"10\" /> image."));
hb = testMakeUnique<PlainTextMarkupBuilder>();
md = testMakeUnique<MarkupDirector>(hb.get());
md->processDocument(&doc);
result = hb->getResult();
regex = QRegularExpression(QStringLiteral(
"^Paragraph with an inline \\[1\\] image.\\n\\n--------\\n\\[1\\] "
"http://kde.org/img/kde41.png\\n$"));
QVERIFY(regex.match(result).hasMatch());
// height and width
doc.setHtml(QStringLiteral(
"Paragraph with an inline <img src=\"http://kde.org/img/kde41.png\" "
"height=\"10\" width=\"10\" /> image."));
hb = testMakeUnique<PlainTextMarkupBuilder>();
md = testMakeUnique<MarkupDirector>(hb.get());
md->processDocument(&doc);
result = hb->getResult();
regex = QRegularExpression(QStringLiteral(
"^Paragraph with an inline \\[1\\] image.\\n\\n--------\\n\\[1\\] "
"http://kde.org/img/kde41.png\\n$"));
QVERIFY(regex.match(result).hasMatch());
}
void TestPlainMarkupOutput::testEachFormatTagSingly()
{
QString result;
QRegularExpression regex;
std::unique_ptr<PlainTextMarkupBuilder> hb;
std::unique_ptr<MarkupDirector> md;
QTextDocument doc;
// Test bold
doc.setHtml(QStringLiteral("Some <b>formatted</b> text."));
hb = testMakeUnique<PlainTextMarkupBuilder>();
md = testMakeUnique<MarkupDirector>(hb.get());
md->processDocument(&doc);
result = hb->getResult();
regex = QRegularExpression(QStringLiteral("^Some \\*formatted\\* text.\\n$"));
QVERIFY(regex.match(result).hasMatch());
// Test Italic
doc.setHtml(QStringLiteral("Some <i>formatted</i> text."));
hb = testMakeUnique<PlainTextMarkupBuilder>();
md = testMakeUnique<MarkupDirector>(hb.get());
md->processDocument(&doc);
result = hb->getResult();
regex = QRegularExpression(QStringLiteral("^Some /formatted/ text.\\n$"));
QVERIFY(regex.match(result).hasMatch());
// Test Underline
doc.setHtml(QStringLiteral("Some <u>formatted</u> text."));
hb = testMakeUnique<PlainTextMarkupBuilder>();
md = testMakeUnique<MarkupDirector>(hb.get());
md->processDocument(&doc);
result = hb->getResult();
regex = QRegularExpression(QStringLiteral("^Some _formatted_ text.\\n$"));
QVERIFY(regex.match(result).hasMatch());
// Test Strikeout
doc.setHtml(QStringLiteral("Some <s>formatted</s> text."));
hb = testMakeUnique<PlainTextMarkupBuilder>();
md = testMakeUnique<MarkupDirector>(hb.get());
md->processDocument(&doc);
result = hb->getResult();
regex = QRegularExpression(QStringLiteral("^Some -formatted- text.\\n$"));
QVERIFY(regex.match(result).hasMatch());
// Test Superscript
doc.setHtml(QStringLiteral("Some <sup>formatted</sup> text."));
hb = testMakeUnique<PlainTextMarkupBuilder>();
md = testMakeUnique<MarkupDirector>(hb.get());
md->processDocument(&doc);
result = hb->getResult();
regex = QRegularExpression(
QStringLiteral("^Some \\^\\{formatted\\} text.\\n$"));
QVERIFY(regex.match(result).hasMatch());
// Test Subscript
doc.setHtml(QStringLiteral("Some <sub>formatted</sub> text."));
hb = testMakeUnique<PlainTextMarkupBuilder>();
md = testMakeUnique<MarkupDirector>(hb.get());
md->processDocument(&doc);
result = hb->getResult();
regex
= QRegularExpression(QStringLiteral("^Some _\\{formatted\\} text.\\n$"));
QVERIFY(regex.match(result).hasMatch());
// Test Foreground
doc.setHtml(QStringLiteral(
"Some <span style=\"color:#ff0000;\">formatted</span> text."));
hb = testMakeUnique<PlainTextMarkupBuilder>();
md = testMakeUnique<MarkupDirector>(hb.get());
md->processDocument(&doc);
result = hb->getResult();
regex = QRegularExpression(QStringLiteral("^Some formatted text.\\n$"));
QVERIFY(regex.match(result).hasMatch());
// Test Background
doc.setHtml(QStringLiteral(
"Some <span style=\"background-color:#ff0000;\">formatted</span> text."));
hb = testMakeUnique<PlainTextMarkupBuilder>();
md = testMakeUnique<MarkupDirector>(hb.get());
md->processDocument(&doc);
result = hb->getResult();
regex = QRegularExpression(QStringLiteral("^Some formatted text.\\n$"));
QVERIFY(regex.match(result).hasMatch());
// Test Font Family
doc.setHtml(QStringLiteral(
"Some <span style=\"font-family:courier;\">formatted</span> text."));
hb = testMakeUnique<PlainTextMarkupBuilder>();
md = testMakeUnique<MarkupDirector>(hb.get());
md->processDocument(&doc);
result = hb->getResult();
regex = QRegularExpression(QStringLiteral("^Some formatted text.\\n$"));
QVERIFY(regex.match(result).hasMatch());
// Test Font Size
doc.setHtml(QStringLiteral(
"Some <span style=\"font-size:20pt;\">formatted</span> text."));
hb = testMakeUnique<PlainTextMarkupBuilder>();
md = testMakeUnique<MarkupDirector>(hb.get());
md->processDocument(&doc);
result = hb->getResult();
regex = QRegularExpression(QStringLiteral("^Some formatted text.\\n$"));
QVERIFY(regex.match(result).hasMatch());
}
void TestPlainMarkupOutput::testHorizontalRule()
{
QTextDocument doc;
doc.setHtml(
QStringLiteral("<p style=\"margin-top:0;margin-bottom:0;\">Foo</p><hr "
"/><p style=\"margin-top:0;margin-bottom:0;\">Bar</p>"));
PlainTextMarkupBuilder hb;
MarkupDirector md(&hb);
md.processDocument(&doc);
auto result = hb.getResult();
auto regex = QRegularExpression(
QStringLiteral("^Foo\\n--------------------\\nBar\\n$"));
QVERIFY(regex.match(result).hasMatch());
}
void TestPlainMarkupOutput::testNewlines()
{
QTextDocument doc;
doc.setHtml(QStringLiteral("<p>Foo</p>\n<br /><br />\n<p>Bar</p>"));
PlainTextMarkupBuilder hb;
MarkupDirector md(&hb);
md.processDocument(&doc);
auto result = hb.getResult();
auto regex = QRegularExpression(QStringLiteral("^Foo\\n\\n\\nBar\\n$"));
QVERIFY(regex.match(result).hasMatch());
}
void TestPlainMarkupOutput::testEmptyParagraphs()
{
QTextDocument doc;
doc.setHtml(QStringLiteral("<p>Foo</p>\n<br /><br />\n<p>Bar</p>"));
PlainTextMarkupBuilder hb;
MarkupDirector md(&hb);
md.processDocument(&doc);
auto result = hb.getResult();
auto regex = QRegularExpression(QStringLiteral("^Foo\\n\\n\\nBar\\n$"));
QVERIFY(regex.match(result).hasMatch());
}
void TestPlainMarkupOutput::testNewlinesThroughQTextCursor()
{
auto doc = new QTextDocument(this);
QTextCursor cursor(doc);
cursor.movePosition(QTextCursor::Start);
cursor.insertText(QStringLiteral("Foo"));
cursor.insertText(QStringLiteral("\n"));
cursor.insertText(QStringLiteral("\n"));
cursor.insertText(QStringLiteral("\n"));
cursor.insertText(QStringLiteral("Bar"));
PlainTextMarkupBuilder hb;
MarkupDirector md(&hb);
md.processDocument(doc);
auto result = hb.getResult();
auto regex = QRegularExpression(QStringLiteral("^Foo\\n\\n\\nBar\\n$"));
QVERIFY(regex.match(result).hasMatch());
}
void TestPlainMarkupOutput::testBrInsideParagraph()
{
QTextDocument doc;
doc.setHtml(QStringLiteral("<p>Foo<br /><br /><br />Bar</p>"));
PlainTextMarkupBuilder hb;
MarkupDirector md(&hb);
md.processDocument(&doc);
auto result = hb.getResult();
// Two paragraphs separated by two line breaks
auto regex = QRegularExpression(QStringLiteral("^Foo\\n\\n\\nBar\\n$"));
QVERIFY(regex.match(result).hasMatch());
}
void TestPlainMarkupOutput::testLongDocument()
{
QTextDocument doc;
QFile sourceHtml(QFINDTESTDATA("sourcehtml"));
QVERIFY(sourceHtml.open(QIODevice::ReadOnly));
doc.setHtml(QString::fromLatin1(sourceHtml.readAll().constData()));
PlainTextMarkupBuilder hb;
MarkupDirector md(&hb);
md.processDocument(&doc);
auto result = hb.getResult();
QVERIFY2(
result.startsWith(QLatin1String("Hello,\nThis is some text\nIt shows how "
"grantlee is used from kmail\n")),
qPrintable(result));
QVERIFY2(result.endsWith(QLatin1String("This is the end of the signature\n")),
qPrintable(result));
}
void TestPlainMarkupOutput::testNestedList()
{
QTextDocument doc;
doc.setHtml(QStringLiteral("<ol>\n"
" <li>Elem1</li>\n"
" <li>Elem2\n"
" <ul>\n"
" <li>Subelem1</li>\n"
" <li>Subelem2</li>\n"
" </ul>\n"
" </li>\n"
" <li>Elem3</li>\n"
" <li>Elem4\n"
" <ul>\n"
" <li>Subelem3</li>\n"
" <li>Subelem4</li>\n"
" </ul>\n"
" </li>\n"
"</ol>"
"<ul type=\"circle\">\n"
" <li>Elem5</li>\n"
"</ul>"));
PlainTextMarkupBuilder hb;
MarkupDirector md(&hb);
md.processDocument(&doc);
auto result = hb.getResult();
const QString expected = QStringLiteral(" 1. Elem1 \n"
" 2. Elem2 \n"
" * Subelem1 \n"
" * Subelem2 \n"
" 3. Elem3 \n"
" 4. Elem4 \n"
" * Subelem3 \n"
" * Subelem4 \n"
" o Elem5\n");
QCOMPARE(result, expected);
}
QTEST_MAIN(TestPlainMarkupOutput)
#include "plainmarkupbuildertest.moc"
|