summaryrefslogtreecommitdiffstats
path: root/tests/auto/testlib/selftests
diff options
context:
space:
mode:
authorGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2020-02-15 00:11:22 +0100
committerGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2020-06-10 16:49:08 +0200
commit8e98a161e993c6636d217276a0f2373d642ff050 (patch)
tree23adce823bfab9795cf7b775d35f14be7baedc10 /tests/auto/testlib/selftests
parentce5931aaf2c9698925366e787d08747a1c60c378 (diff)
Long live std::pair!
Make QPair an alias for std::pair, and qMakePair just a forwarder towards std::make_pair. Why? Fundamentally to ditch a bunch of NIH code; gain for free structured bindings, std::tuple and std::reference_wrapper compatibility, and so on. Breakages: * Some that code manually forward declares QPair. We don't care about it (<QContainerFwd> is the proper way). * Some code that overloads on std::pair and QPair. Luckily it's mostly centralized: debug, metatypes, testing macros. Just remove the QPair overload. * Usages of qMakePair forcing the template type parameters. There are a handful of these in qtbase, but only one was actually broken. * std::pair is NOT (and will never likely be) trivially copiable. This is agreed to be a mistake done by practically all implementations in C++11, can can't be fixed without breaking ABI. Some code using QPair assuming it's trivially copiable may break; exactly one occurrence was in qtbase. * QMetaType logic extracts the type names in two different ways, one by looking at the source code string (e.g. extracted by moc) and one via some ad-hoc reflection in C++. We need to make "QPair" (as spelled in the source code) be the same as "std::pair" (gathered via reflection, which will see through the alias) when compared. The way it's already done e.g. for QList is by actually replacing the moc-extracted name with the name of the actual type used in C++; do the same here. On libc++, std::pair is actually in an inline namespace -- i.e. std::__1::pair; the reflection will extract and store "std::__1::pair" so we need an ad-hoc fix to QMetaType. [ChangeLog][QtCore][QPair] QPair is now an alias to std::pair, and does not exist as a class in Qt any more. This may break code such as functions overloaded for both QPair and std::pair. Usually, the overload taking a QPair can be safely discarded, leaving only the one taking a std::pair. QPair API has not changed, and qMakePair is still available for compatibility (although new code is encouraged to use std::pair and std::make_pair directly instead). Change-Id: I7725c751bf23946cde577b1406e86a336c0a3dcf Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'tests/auto/testlib/selftests')
-rw-r--r--tests/auto/testlib/selftests/expected_pairdiagnostics.junitxml4
-rw-r--r--tests/auto/testlib/selftests/expected_pairdiagnostics.lightxml4
-rw-r--r--tests/auto/testlib/selftests/expected_pairdiagnostics.tap8
-rw-r--r--tests/auto/testlib/selftests/expected_pairdiagnostics.teamcity2
-rw-r--r--tests/auto/testlib/selftests/expected_pairdiagnostics.txt4
-rw-r--r--tests/auto/testlib/selftests/expected_pairdiagnostics.xml4
6 files changed, 13 insertions, 13 deletions
diff --git a/tests/auto/testlib/selftests/expected_pairdiagnostics.junitxml b/tests/auto/testlib/selftests/expected_pairdiagnostics.junitxml
index cf2a30b84a..653dde11c0 100644
--- a/tests/auto/testlib/selftests/expected_pairdiagnostics.junitxml
+++ b/tests/auto/testlib/selftests/expected_pairdiagnostics.junitxml
@@ -8,8 +8,8 @@
<testcase result="pass" name="initTestCase"/>
<testcase result="fail" name="testQPair">
<failure message="Compared values are not the same
- Actual (pair1): &quot;QPair(1,1)&quot;
- Expected (pair2): &quot;QPair(1,2)&quot;" result="fail"/>
+ Actual (pair1): &quot;std::pair(1,1)&quot;
+ Expected (pair2): &quot;std::pair(1,2)&quot;" result="fail"/>
</testcase>
<testcase result="fail" name="testStdPair">
<failure message="Compared values are not the same
diff --git a/tests/auto/testlib/selftests/expected_pairdiagnostics.lightxml b/tests/auto/testlib/selftests/expected_pairdiagnostics.lightxml
index 7a842e9d36..e4ceacc9e3 100644
--- a/tests/auto/testlib/selftests/expected_pairdiagnostics.lightxml
+++ b/tests/auto/testlib/selftests/expected_pairdiagnostics.lightxml
@@ -10,8 +10,8 @@
<TestFunction name="testQPair">
<Incident type="fail" file="qtbase/tests/auto/testlib/selftests/pairdiagnostics/tst_pairdiagnostics.cpp" line="0">
<Description><![CDATA[Compared values are not the same
- Actual (pair1): "QPair(1,1)"
- Expected (pair2): "QPair(1,2)"]]></Description>
+ Actual (pair1): "std::pair(1,1)"
+ Expected (pair2): "std::pair(1,2)"]]></Description>
</Incident>
<Duration msecs="0"/>
</TestFunction>
diff --git a/tests/auto/testlib/selftests/expected_pairdiagnostics.tap b/tests/auto/testlib/selftests/expected_pairdiagnostics.tap
index 9c45880c2d..d6e1a0b22f 100644
--- a/tests/auto/testlib/selftests/expected_pairdiagnostics.tap
+++ b/tests/auto/testlib/selftests/expected_pairdiagnostics.tap
@@ -5,10 +5,10 @@ not ok 2 - testQPair()
---
type: QCOMPARE
message: Compared values are not the same
- wanted: "QPair(1,2)" (pair2)
- found: "QPair(1,1)" (pair1)
- expected: "QPair(1,2)" (pair2)
- actual: "QPair(1,1)" (pair1)
+ wanted: "std::pair(1,2)" (pair2)
+ found: "std::pair(1,1)" (pair1)
+ expected: "std::pair(1,2)" (pair2)
+ actual: "std::pair(1,1)" (pair1)
at: tst_PairDiagnostics::testQPair() (qtbase/tests/auto/testlib/selftests/pairdiagnostics/tst_pairdiagnostics.cpp:51)
file: qtbase/tests/auto/testlib/selftests/pairdiagnostics/tst_pairdiagnostics.cpp
line: 51
diff --git a/tests/auto/testlib/selftests/expected_pairdiagnostics.teamcity b/tests/auto/testlib/selftests/expected_pairdiagnostics.teamcity
index 9068e2c45b..a86f4fa254 100644
--- a/tests/auto/testlib/selftests/expected_pairdiagnostics.teamcity
+++ b/tests/auto/testlib/selftests/expected_pairdiagnostics.teamcity
@@ -2,7 +2,7 @@
##teamcity[testStarted name='initTestCase()' flowId='tst_PairDiagnostics']
##teamcity[testFinished name='initTestCase()' flowId='tst_PairDiagnostics']
##teamcity[testStarted name='testQPair()' flowId='tst_PairDiagnostics']
-##teamcity[testFailed name='testQPair()' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/pairdiagnostics/tst_pairdiagnostics.cpp(0)|]' details='Compared values are not the same|n Actual (pair1): "QPair(1,1)"|n Expected (pair2): "QPair(1,2)"' flowId='tst_PairDiagnostics']
+##teamcity[testFailed name='testQPair()' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/pairdiagnostics/tst_pairdiagnostics.cpp(0)|]' details='Compared values are not the same|n Actual (pair1): "std::pair(1,1)"|n Expected (pair2): "std::pair(1,2)"' flowId='tst_PairDiagnostics']
##teamcity[testFinished name='testQPair()' flowId='tst_PairDiagnostics']
##teamcity[testStarted name='testStdPair()' flowId='tst_PairDiagnostics']
##teamcity[testFailed name='testStdPair()' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/pairdiagnostics/tst_pairdiagnostics.cpp(0)|]' details='Compared values are not the same|n Actual (pair1): "std::pair(1,1)"|n Expected (pair2): "std::pair(1,2)"' flowId='tst_PairDiagnostics']
diff --git a/tests/auto/testlib/selftests/expected_pairdiagnostics.txt b/tests/auto/testlib/selftests/expected_pairdiagnostics.txt
index 5e29888ba6..cbb8b764ff 100644
--- a/tests/auto/testlib/selftests/expected_pairdiagnostics.txt
+++ b/tests/auto/testlib/selftests/expected_pairdiagnostics.txt
@@ -2,8 +2,8 @@
Config: Using QtTest library
PASS : tst_PairDiagnostics::initTestCase()
FAIL! : tst_PairDiagnostics::testQPair() Compared values are not the same
- Actual (pair1): "QPair(1,1)"
- Expected (pair2): "QPair(1,2)"
+ Actual (pair1): "std::pair(1,1)"
+ Expected (pair2): "std::pair(1,2)"
Loc: [qtbase/tests/auto/testlib/selftests/pairdiagnostics/tst_pairdiagnostics.cpp(0)]
FAIL! : tst_PairDiagnostics::testStdPair() Compared values are not the same
Actual (pair1): "std::pair(1,1)"
diff --git a/tests/auto/testlib/selftests/expected_pairdiagnostics.xml b/tests/auto/testlib/selftests/expected_pairdiagnostics.xml
index cd98e4d36e..89e8ca49a6 100644
--- a/tests/auto/testlib/selftests/expected_pairdiagnostics.xml
+++ b/tests/auto/testlib/selftests/expected_pairdiagnostics.xml
@@ -12,8 +12,8 @@
<TestFunction name="testQPair">
<Incident type="fail" file="qtbase/tests/auto/testlib/selftests/pairdiagnostics/tst_pairdiagnostics.cpp" line="0">
<Description><![CDATA[Compared values are not the same
- Actual (pair1): "QPair(1,1)"
- Expected (pair2): "QPair(1,2)"]]></Description>
+ Actual (pair1): "std::pair(1,1)"
+ Expected (pair2): "std::pair(1,2)"]]></Description>
</Incident>
<Duration msecs="0"/>
</TestFunction>