summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2010-02-18 18:44:31 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2010-02-18 18:44:31 (GMT)
commit03f7e1f5315f076fcb7234b3d29d120d6779595c (patch)
tree565b5d07e6d84fd0e9d6ff9c299998b01235456f /tests
parentc18beac8163634b48bbf1e7280923e96f5ef0a51 (diff)
parent26c367b9b9e220056af3a47eced366d6d187a890 (diff)
downloadQt-03f7e1f5315f076fcb7234b3d29d120d6779595c.zip
Qt-03f7e1f5315f076fcb7234b3d29d120d6779595c.tar.gz
Qt-03f7e1f5315f076fcb7234b3d29d120d6779595c.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: (22 commits) 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 optimize QList::mid() optimization: use QList::reserve() in QSet::toList() add QList::reserve() ...
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qlist/tst_qlist.cpp10
-rw-r--r--tests/auto/qstring/tst_qstring.cpp50
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()