diff options
author | Konstantin Ritt <ritt.ks@gmail.com> | 2012-05-25 05:00:28 +0300 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-06-07 21:18:36 +0200 |
commit | 8aac04f705c8f9e4193444b904f9819aea85b326 (patch) | |
tree | 6e1b0117717551f3fdeb11969dff98b4e4444e0f /tests/auto/corelib/tools/qtextboundaryfinder | |
parent | 824180a12249e48c0e3280fec64940825ce0aa6e (diff) |
QTextBoundaryFinder: Consider soft hyphen as line breaking opportunity
SoftHyphen enum value was added to specify such a boundary reason
Change-Id: I4248909eed6ab8cbca419de4dcf9fe917620a158
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Diffstat (limited to 'tests/auto/corelib/tools/qtextboundaryfinder')
-rw-r--r-- | tests/auto/corelib/tools/qtextboundaryfinder/tst_qtextboundaryfinder.cpp | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/tests/auto/corelib/tools/qtextboundaryfinder/tst_qtextboundaryfinder.cpp b/tests/auto/corelib/tools/qtextboundaryfinder/tst_qtextboundaryfinder.cpp index d8dd0f68e4..e5a5f99814 100644 --- a/tests/auto/corelib/tools/qtextboundaryfinder/tst_qtextboundaryfinder.cpp +++ b/tests/auto/corelib/tools/qtextboundaryfinder/tst_qtextboundaryfinder.cpp @@ -70,6 +70,8 @@ private slots: void lineBoundaries_manual(); void fastConstructor(); + void isAtSoftHyphen_data(); + void isAtSoftHyphen(); void thaiLineBreak(); }; @@ -485,7 +487,7 @@ void tst_QTextBoundaryFinder::lineBoundaries_manual_data() QChar s[] = { 0x0061, 0x00AD, 0x0062, 0x0009, 0x0063, 0x0064 }; QString testString(s, sizeof(s)/sizeof(s[0])); QList<int> expectedBreakPositions; - expectedBreakPositions << 0 << 4 << 6; + expectedBreakPositions << 0 << 2 << 4 << 6; QTest::newRow("x(AL)x(BA)+(AL)x(BA)+(AL)x(AL)+") << testString << expectedBreakPositions; } @@ -522,6 +524,34 @@ void tst_QTextBoundaryFinder::fastConstructor() QCOMPARE(finder.boundaryReasons(), QTextBoundaryFinder::NotAtBoundary); } +void tst_QTextBoundaryFinder::isAtSoftHyphen_data() +{ + QTest::addColumn<QString>("testString"); + QTest::addColumn<QList<int> >("expectedBreakPositions"); + + QString testString = QString::fromUtf8("I a-m break-able"); + testString.replace(QLatin1Char('-'), QChar(0x00AD)); + QList<int> expectedBreakPositions; + expectedBreakPositions << 0 << 2 << 4 << 6 << 12 << 16; + QTest::newRow("Soft Hyphen") << testString << expectedBreakPositions; +} + +void tst_QTextBoundaryFinder::isAtSoftHyphen() +{ + QFETCH(QString, testString); + QFETCH(QList<int>, expectedBreakPositions); + + doTestData(testString, expectedBreakPositions, QTextBoundaryFinder::Line); + + QTextBoundaryFinder boundaryFinder(QTextBoundaryFinder::Line, testString); + for (int i = 0; (i = testString.indexOf(QChar(0x00AD), i)) != -1; ++i) { + QVERIFY(expectedBreakPositions.contains(i + 1)); + boundaryFinder.setPosition(i + 1); + QVERIFY(boundaryFinder.isAtBoundary()); + QVERIFY(boundaryFinder.boundaryReasons() == QTextBoundaryFinder::SoftHyphen); + } +} + #include <qlibrary.h> #define LIBTHAI_MAJOR 0 |