Exemple #1
0
void TestStoryText::initST()
{
    StoryText story;
    QCOMPARE(story.length(), 0);
    story.insertChars(0, "Hallo Welt");
    QCOMPARE(story.nrOfParagraphs(), 1u);
    QCOMPARE(story.nrOfRuns(), 1u);
}
Exemple #2
0
void TestStoryText::removeCharStyle()
{
    StoryText story;
    story.insertChars(0,
                      QString("0123456789") + SpecialChars::PARSEP +
                      QString("abcdefghijklmnopqrstuvwxyz") + SpecialChars::PARSEP +
                      QString("ABCDEFGHIJKLMNOPQRSTUVWXYZ"));
    QCOMPARE(story.nrOfRuns(), 3u);
    CharStyle cs;
    cs.setFontSize(10);
    story.applyCharStyle(5 + 26 + 1,  26 + 1, cs);
    story.removeChars(11, 26+1);
    QCOMPARE(story.nrOfRuns(), 3u);
    QCOMPARE(story.startOfRun(0), 0);
    QCOMPARE(story.endOfRun(0), 11);
    QCOMPARE(story.startOfRun(1), 11);
    QCOMPARE(story.endOfRun(1), 5 + 26 + 1);
    QCOMPARE(story.startOfRun(2), 5  + 26 + 1);
    QCOMPARE(story.endOfRun(2), 11 + 26);
}
Exemple #3
0
void TestStoryText::insertPar()
{
    StoryText story;
    story.insertChars(0, QString("Hallo") + SpecialChars::PARSEP + QString("Welt"));
    QCOMPARE(story.length(), 10);
    QCOMPARE(story.nrOfParagraphs(), 2u);
    QCOMPARE(story.nrOfRuns(), 2u);
    for (int i =0; i <= story.nrOfParagraphs(); ++i)
        qDebug() << "par" << i << "offset" << story.startOfParagraph(i);
    QCOMPARE(story.text(0,10).length(), 10);
    QCOMPARE(story.text(0, story.length()), QString("Hallo") + SpecialChars::PARSEP + QString("Welt"));
}