summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/tools/qvector/tst_qvector.cpp
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2015-03-27 20:56:44 +0100
committerMarc Mutz <marc.mutz@kdab.com>2015-04-02 18:49:20 +0000
commit34c6fbf846b12fa11a863e5c0d3ad5651eb5db48 (patch)
tree0aaf60f48be009caf79567bbc105f3f056626bd2 /tests/auto/corelib/tools/qvector/tst_qvector.cpp
parent929cc27ffe7b35177e34ac8728bdbeeb5464cd6b (diff)
QVector: add relational operators <,<=,>,>=
std::vector has them, too. [ChangeLog][QtCore][QVector] Added relational operators <, <=, >, >= if the element type supports operator<. Change-Id: I0bcb22dfcc43cb0362f17b4e06154ce18646580a Reviewed-by: Kai Koehne <kai.koehne@theqtcompany.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'tests/auto/corelib/tools/qvector/tst_qvector.cpp')
-rw-r--r--tests/auto/corelib/tools/qvector/tst_qvector.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/auto/corelib/tools/qvector/tst_qvector.cpp b/tests/auto/corelib/tools/qvector/tst_qvector.cpp
index 69da6e450e..e577107040 100644
--- a/tests/auto/corelib/tools/qvector/tst_qvector.cpp
+++ b/tests/auto/corelib/tools/qvector/tst_qvector.cpp
@@ -123,6 +123,13 @@ struct Custom {
return i == other.i;
}
+ bool operator<(const Custom &other) const
+ {
+ check(&other);
+ check(this);
+ return i < other.i;
+ }
+
Custom &operator=(const Custom &other)
{
check(&other);
@@ -2076,6 +2083,19 @@ void tst_QVector::testOperators() const
// ==
QVERIFY(myvec == combined);
+ // <, >, <=, >=
+ QVERIFY(!(myvec < combined));
+ QVERIFY(!(myvec > combined));
+ QVERIFY( myvec <= combined);
+ QVERIFY( myvec >= combined);
+ combined.push_back("G");
+ QVERIFY( myvec < combined);
+ QVERIFY(!(myvec > combined));
+ QVERIFY( myvec <= combined);
+ QVERIFY(!(myvec >= combined));
+ QVERIFY(combined > myvec);
+ QVERIFY(combined >= myvec);
+
// []
QCOMPARE(myvec[0], QLatin1String("A"));
QCOMPARE(myvec[1], QLatin1String("B"));