diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2010-02-19 23:07:13 (GMT) |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2010-02-19 23:07:13 (GMT) |
commit | 8f10ca802dee1ed110f301191c4a56a85575033c (patch) | |
tree | 4465150efc232421953b6c7f1885c7738ce1e395 /tests/auto | |
parent | 01498eb9a44f3b15e517e81b309087fbbf1b93bf (diff) | |
parent | 402da10939d1d3a5973caaf9deaef0f9f10d834a (diff) | |
download | Qt-8f10ca802dee1ed110f301191c4a56a85575033c.zip Qt-8f10ca802dee1ed110f301191c4a56a85575033c.tar.gz Qt-8f10ca802dee1ed110f301191c4a56a85575033c.tar.bz2 |
Merge branch 'master' of scm.dev.nokia.troll.no:qt/berlin-staging-1 into master-integration
* 'master' of scm.dev.nokia.troll.no:qt/berlin-staging-1: (25 commits)
Add convenience function QTextCursor::positionInBlock()
Fixed URL in Russian translation.
Designer/Resourceview: Suppress warning about QFileInfo on empty path.
optimize qstring::simplified()
Revert optimizations to QString::append
unbreak QList::append() and co. again
Implement bookmark manager widget.
optimization: use QList::reserve() and QVector::reserve()
amend "purge msvc.net and msvc2002 makespecs"
Added QPlainTextEditor::anchorAt(const QPoint &pos)
Fix memmory leak.
Fix spacing.
Prevent renaming the bookmarks menu root item, it's just a placeholder.
Fix broken set last shown pagen when the last page was about:blank.
Move launch with external app in base class.
Make sure the bookmarks menu updates on add/ remove as well.
Fix broken Drag&Drop, reset and clear the model if we set new bookmarks.
avoid double reallocations in appending operations
avoid double reallocation in string-growing replace() case
optimize qHash() some more
...
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/qlist/tst_qlist.cpp | 10 | ||||
-rw-r--r-- | tests/auto/qstring/tst_qstring.cpp | 50 |
2 files changed, 53 insertions, 7 deletions
diff --git a/tests/auto/qlist/tst_qlist.cpp b/tests/auto/qlist/tst_qlist.cpp index 59b2c7b..a590fca 100644 --- a/tests/auto/qlist/tst_qlist.cpp +++ b/tests/auto/qlist/tst_qlist.cpp @@ -60,6 +60,7 @@ private slots: void length() const; void lengthSignature() const; void append() const; + void mid() const; }; void tst_QList::length() const @@ -129,5 +130,14 @@ void tst_QList::append() const } +void tst_QList::mid() const +{ + QList<QString> list; + list << "foo" << "bar" << "baz" << "bak" << "buck" << "hello" << "kitty"; + + QCOMPARE(list.mid(3, 3), + QList<QString>() << "bak" << "buck" << "hello"); +} + QTEST_APPLESS_MAIN(tst_QList) #include "tst_qlist.moc" diff --git a/tests/auto/qstring/tst_qstring.cpp b/tests/auto/qstring/tst_qstring.cpp index c9b3436..9c9524a 100644 --- a/tests/auto/qstring/tst_qstring.cpp +++ b/tests/auto/qstring/tst_qstring.cpp @@ -120,6 +120,7 @@ private slots: void operator_eqeq_nullstring(); void operator_smaller(); void insert(); + void simplified_data(); void simplified(); void trimmed(); void toLower(); @@ -1592,16 +1593,51 @@ void tst_QString::trimmed() QCOMPARE(a.trimmed(),(QString)"a"); } +void tst_QString::simplified_data() +{ + QTest::addColumn<QString>("full" ); + QTest::addColumn<QString>("simple" ); + + QTest::newRow("null") << QString() << QString(); + QTest::newRow("empty") << "" << ""; + QTest::newRow("one char") << "a" << "a"; + QTest::newRow("one word") << "foo" << "foo"; + QTest::newRow("chars trivial") << "a b" << "a b"; + QTest::newRow("words trivial") << "foo bar" << "foo bar"; + QTest::newRow("allspace") << " \t\v " << ""; + QTest::newRow("char trailing") << "a " << "a"; + QTest::newRow("char trailing tab") << "a\t" << "a"; + QTest::newRow("char multitrailing") << "a " << "a"; + QTest::newRow("char multitrailing tab") << "a \t" << "a"; + QTest::newRow("char leading") << " a" << "a"; + QTest::newRow("char leading tab") << "\ta" << "a"; + QTest::newRow("char multileading") << " a" << "a"; + QTest::newRow("char multileading tab") << "\t a" << "a"; + QTest::newRow("chars apart") << "a b" << "a b"; + QTest::newRow("words apart") << "foo bar" << "foo bar"; + QTest::newRow("enclosed word") << " foo \t " << "foo"; + QTest::newRow("enclosed chars apart") << " a b " << "a b"; + QTest::newRow("enclosed words apart") << " foo bar " << "foo bar"; + QTest::newRow("chars apart posttab") << "a \tb" << "a b"; + QTest::newRow("chars apart pretab") << "a\t b" << "a b"; + QTest::newRow("many words") << " just some random\ttext here" << "just some random text here"; +} + void tst_QString::simplified() { - QString j; - j.simplified(); + QFETCH(QString, full); + QFETCH(QString, simple); - QString a; - a = "a "; - QCOMPARE(a.simplified(),(QString)"a"); - a=" a b "; - QCOMPARE(a.simplified(),(QString)"a b"); + QString result = full.simplified(); + if (simple.isNull()) { + QVERIFY2(result.isNull(), qPrintable("'" + full + "' did not yield null: " + result)); + } else if (simple.isEmpty()) { + QVERIFY2(result.isEmpty() && !result.isNull(), qPrintable("'" + full + "' did not yield empty: " + result)); + } else { + QCOMPARE(result, simple); + if (full == simple) + QVERIFY(result.isSharedWith(full)); + } } void tst_QString::insert() |