summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qbitarray/tst_qbitarray.cpp9
-rw-r--r--tests/auto/qbytearray/tst_qbytearray.cpp9
-rw-r--r--tests/auto/qcontiguouscache/tst_qcontiguouscache.cpp13
-rw-r--r--tests/auto/qhash/tst_qhash.cpp11
-rw-r--r--tests/auto/qlist/tst_qlist.cpp7
-rw-r--r--tests/auto/qmap/tst_qmap.cpp12
-rw-r--r--tests/auto/qpolygon/tst_qpolygon.cpp10
-rw-r--r--tests/auto/qset/tst_qset.cpp11
-rw-r--r--tests/auto/qstring/tst_qstring.cpp11
-rw-r--r--tests/auto/qvector/tst_qvector.cpp12
10 files changed, 105 insertions, 0 deletions
diff --git a/tests/auto/qbitarray/tst_qbitarray.cpp b/tests/auto/qbitarray/tst_qbitarray.cpp
index 30f4f58..7b9543e 100644
--- a/tests/auto/qbitarray/tst_qbitarray.cpp
+++ b/tests/auto/qbitarray/tst_qbitarray.cpp
@@ -88,6 +88,7 @@ private slots:
void countBits();
void countBits2();
void isEmpty();
+ void swap();
void fill();
void toggleBit_data();
void toggleBit();
@@ -269,6 +270,14 @@ void tst_QBitArray::isEmpty()
QVERIFY(a1.size() == 2);
}
+void tst_QBitArray::swap()
+{
+ QBitArray b1 = QStringToQBitArray("1"), b2 = QStringToQBitArray("10");
+ b1.swap(b2);
+ QCOMPARE(b1,QStringToQBitArray("10"));
+ QCOMPARE(b2,QStringToQBitArray("1"));
+}
+
void tst_QBitArray::fill()
{
int N = 64;
diff --git a/tests/auto/qbytearray/tst_qbytearray.cpp b/tests/auto/qbytearray/tst_qbytearray.cpp
index 0dc2282..c291c6a 100644
--- a/tests/auto/qbytearray/tst_qbytearray.cpp
+++ b/tests/auto/qbytearray/tst_qbytearray.cpp
@@ -71,6 +71,7 @@ public slots:
void init();
void cleanup();
private slots:
+ void swap();
void qCompress_data();
#ifndef QT_NO_COMPRESS
void qCompress();
@@ -453,6 +454,14 @@ void tst_QByteArray::split()
QCOMPARE(list.count(), size);
}
+void tst_QByteArray::swap()
+{
+ QByteArray b1 = "b1", b2 = "b2";
+ b1.swap(b2);
+ QCOMPARE(b1, QByteArray("b2"));
+ QCOMPARE(b2, QByteArray("b1"));
+}
+
void tst_QByteArray::base64_data()
{
QTest::addColumn<QByteArray>("rawdata");
diff --git a/tests/auto/qcontiguouscache/tst_qcontiguouscache.cpp b/tests/auto/qcontiguouscache/tst_qcontiguouscache.cpp
index f64e815..568ba06 100644
--- a/tests/auto/qcontiguouscache/tst_qcontiguouscache.cpp
+++ b/tests/auto/qcontiguouscache/tst_qcontiguouscache.cpp
@@ -55,6 +55,8 @@ public:
virtual ~tst_QContiguousCache() {}
private slots:
void empty();
+ void swap();
+
void append_data();
void append();
@@ -99,6 +101,17 @@ void tst_QContiguousCache::empty()
QCOMPARE(c.capacity(), 10);
}
+void tst_QContiguousCache::swap()
+{
+ QContiguousCache<int> c1(10), c2(100);
+ c1.append(1);
+ c1.swap(c2);
+ QCOMPARE(c1.capacity(), 100);
+ QCOMPARE(c1.count(), 0 );
+ QCOMPARE(c2.capacity(), 10 );
+ QCOMPARE(c2.count(), 1 );
+}
+
void tst_QContiguousCache::append_data()
{
QTest::addColumn<int>("start");
diff --git a/tests/auto/qhash/tst_qhash.cpp b/tests/auto/qhash/tst_qhash.cpp
index 3a7b54a..ea6e010 100644
--- a/tests/auto/qhash/tst_qhash.cpp
+++ b/tests/auto/qhash/tst_qhash.cpp
@@ -60,6 +60,7 @@ private slots:
void erase();
void key();
+ void swap();
void count(); // copied from tst_QMap
void clear(); // copied from tst_QMap
void empty(); // copied from tst_QMap
@@ -553,6 +554,16 @@ void tst_QHash::key()
}
}
+void tst_QHash::swap()
+{
+ QHash<int,QString> h1, h2;
+ h1[0] = "h1[0]";
+ h2[1] = "h2[1]";
+ h1.swap(h2);
+ QCOMPARE(h1.value(1),QLatin1String("h2[1]"));
+ QCOMPARE(h2.value(0),QLatin1String("h1[0]"));
+}
+
// copied from tst_QMap
void tst_QHash::clear()
{
diff --git a/tests/auto/qlist/tst_qlist.cpp b/tests/auto/qlist/tst_qlist.cpp
index 14b8057..9ab7cf7 100644
--- a/tests/auto/qlist/tst_qlist.cpp
+++ b/tests/auto/qlist/tst_qlist.cpp
@@ -499,6 +499,13 @@ void tst_QList::swap() const
// swap again
list.swap(1, 2);
QCOMPARE(list, QList<QString>() << "baz" << "foo" << "bar");
+
+ QList<QString> list2;
+ list2 << "alpha" << "beta";
+
+ list.swap(list2);
+ QCOMPARE(list, QList<QString>() << "alpha" << "beta");
+ QCOMPARE(list2, QList<QString>() << "baz" << "foo" << "bar");
}
void tst_QList::takeAt() const
diff --git a/tests/auto/qmap/tst_qmap.cpp b/tests/auto/qmap/tst_qmap.cpp
index a1b8de7..311b0b6 100644
--- a/tests/auto/qmap/tst_qmap.cpp
+++ b/tests/auto/qmap/tst_qmap.cpp
@@ -65,6 +65,8 @@ private slots:
void beginEnd();
void key();
+ void swap();
+
void operator_eq();
void empty();
@@ -392,6 +394,16 @@ void tst_QMap::key()
}
}
+void tst_QMap::swap()
+{
+ QMap<int,QString> m1, m2;
+ m1[0] = "m1[0]";
+ m2[1] = "m2[1]";
+ m1.swap(m2);
+ QCOMPARE(m1.value(1),QLatin1String("m2[1]"));
+ QCOMPARE(m2.value(0),QLatin1String("m1[0]"));
+}
+
void tst_QMap::operator_eq()
{
{
diff --git a/tests/auto/qpolygon/tst_qpolygon.cpp b/tests/auto/qpolygon/tst_qpolygon.cpp
index eb7cbd5..a79c0c8 100644
--- a/tests/auto/qpolygon/tst_qpolygon.cpp
+++ b/tests/auto/qpolygon/tst_qpolygon.cpp
@@ -63,6 +63,7 @@ public:
private slots:
void makeEllipse();
+ void swap();
};
tst_QPolygon::tst_QPolygon()
@@ -91,5 +92,14 @@ void tst_QPolygon::makeEllipse()
QVERIFY( !err );
}
+void tst_QPolygon::swap()
+{
+ QPolygon p1(QVector<QPoint>() << QPoint(0,0) << QPoint(10,10) << QPoint(-10,10));
+ QPolygon p2(QVector<QPoint>() << QPoint(0,0) << QPoint( 0,10) << QPoint( 10,10) << QPoint(10,0));
+ p1.swap(p2);
+ QCOMPARE(p1.count(),4);
+ QCOMPARE(p2.count(),3);
+}
+
QTEST_APPLESS_MAIN(tst_QPolygon)
#include "tst_qpolygon.moc"
diff --git a/tests/auto/qset/tst_qset.cpp b/tests/auto/qset/tst_qset.cpp
index 319cdf4..6f377f5 100644
--- a/tests/auto/qset/tst_qset.cpp
+++ b/tests/auto/qset/tst_qset.cpp
@@ -65,6 +65,7 @@ public:
private slots:
void operator_eq();
+ void swap();
void size();
void capacity();
void reserve();
@@ -145,6 +146,16 @@ void tst_QSet::operator_eq()
}
}
+void tst_QSet::swap()
+{
+ QSet<int> s1, s2;
+ s1.insert(1);
+ s2.insert(2);
+ s1.swap(s2);
+ QCOMPARE(*s1.begin(),2);
+ QCOMPARE(*s2.begin(),1);
+}
+
void tst_QSet::size()
{
QSet<int> set;
diff --git a/tests/auto/qstring/tst_qstring.cpp b/tests/auto/qstring/tst_qstring.cpp
index 003332c..c3f14f2 100644
--- a/tests/auto/qstring/tst_qstring.cpp
+++ b/tests/auto/qstring/tst_qstring.cpp
@@ -114,6 +114,7 @@ private slots:
void remove_string();
void remove_regexp_data();
void remove_regexp();
+ void swap();
void prepend();
void prepend_bytearray_data();
void prepend_bytearray();
@@ -1852,6 +1853,16 @@ void tst_QString::operator_pluseq_bytearray()
}
}
+void tst_QString::swap()
+{
+ QString s1, s2;
+ s1 = "s1";
+ s2 = "s2";
+ s1.swap(s2);
+ QCOMPARE(s1,QLatin1String("s2"));
+ QCOMPARE(s2,QLatin1String("s1"));
+}
+
void tst_QString::prepend()
{
QString a;
diff --git a/tests/auto/qvector/tst_qvector.cpp b/tests/auto/qvector/tst_qvector.cpp
index a04ce60..b3decc8 100644
--- a/tests/auto/qvector/tst_qvector.cpp
+++ b/tests/auto/qvector/tst_qvector.cpp
@@ -80,6 +80,7 @@ private slots:
void remove() const;
void size() const;
void startsWith() const;
+ void swap() const;
void toList() const;
void toStdVector() const;
void value() const;
@@ -579,6 +580,17 @@ void tst_QVector::startsWith() const
QVERIFY(myvec.startsWith(1));
}
+void tst_QVector::swap() const
+{
+ QVector<int> v1, v2;
+ v1 << 1 << 2 << 3;
+ v2 << 4 << 5 << 6;
+
+ v1.swap(v2);
+ QCOMPARE(v1,QVector<int>() << 4 << 5 << 6);
+ QCOMPARE(v2,QVector<int>() << 1 << 2 << 3);
+}
+
void tst_QVector::toList() const
{
QVector<QString> myvec;