summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@woboq.com>2012-04-22 22:04:46 +0200
committerQt by Nokia <qt-info@nokia.com>2012-05-11 01:42:02 +0200
commitf92fdd190d056fe929f723e3f2ce9e0c0b141cec (patch)
tree55590a2a6fd346031c8950a13b9ddccf640fc485 /tests
parent7226361aed3259b7f4b68e1836f17b3e698c30af (diff)
Implement the move constructor for containers.
This changes all the containers that uses QtPrivate::RefCount (QMap already had one), and QVariant In Qt 4.8, it was pointless to have the move constructor because we did not have quick way to re-initialize a null container. (shared_null still needed to be refcounted) But now that we have RefCount, and that the shared_null do not have reference count, we can implement a fast move constructor that do not generate code to increment the reference count. Change-Id: I2bc3c6ae96983f08aa7b1c7cb98d44a89255160b Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@nokia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/other/collections/tst_collections.cpp20
1 files changed, 19 insertions, 1 deletions
diff --git a/tests/auto/other/collections/tst_collections.cpp b/tests/auto/other/collections/tst_collections.cpp
index 472dd5020e..26e3ccfce4 100644
--- a/tests/auto/other/collections/tst_collections.cpp
+++ b/tests/auto/other/collections/tst_collections.cpp
@@ -2419,6 +2419,14 @@ bool isSharable(const Container &container)
return !container.isDetached();
}
+template <class Container> Container newInstance() {
+ Container container;
+ populate(container);
+ if (!container.isEmpty())
+ return container;
+ return Container();
+}
+
template <class Container, class ContainerMutableIterator>
void testContainer()
{
@@ -2539,10 +2547,20 @@ void testContainer()
QVERIFY(!c2.isDetached());
QVERIFY(!c3.isDetached());
}
+
+ /* test that the move operators work properly */
+ {
+ Container c1 = Container(newInstance<Container>());
+ QVERIFY(c1.size() == 4);
+ QVERIFY(c1 == newInstance<Container>());
+ c1 = newInstance<Container>();
+ QVERIFY(c1.size() == 4);
+ QVERIFY(c1 == newInstance<Container>());
+ }
}
#define TEST_SEQUENTIAL_CONTAINER(Container) \
- testContainer<Q##Container<int>, QMutable##Container##Iterator<int> >()
+ testContainer<Q##Container<int>, QMutable##Container##Iterator<int> >() \
#define TEST_ASSOCIATIVE_CONTAINER(Container) \
testContainer<Q##Container<int, int>, QMutable##Container##Iterator<int, int> >()