Skip to content

Commit

Permalink
Add a configure check for C++20 and compile more tests in more C++ ve…
Browse files Browse the repository at this point in the history
…rsions

Increases test coverage.

Change-Id: Ie996fea85401175d5fc5a7182fb2a0c35e7739c7
Reviewed-on: https://codereview.kdab.com/c/kdab/KDToolBox/+/98817
Tested-by: Continuous Integration <[email protected]>
Reviewed-by: Sérgio Martins <[email protected]>
  • Loading branch information
marc-kdab committed Jun 18, 2021
1 parent cc03c86 commit 30801e4
Show file tree
Hide file tree
Showing 17 changed files with 101 additions and 17 deletions.
5 changes: 5 additions & 0 deletions KDToolBox.pro
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
TEMPLATE = subdirs

include(configtests.pri)

config_cpp20:message("Enabling C++20 tests")

SUBDIRS += \
cpp \
qt \
Expand Down
3 changes: 3 additions & 0 deletions config.tests/cpp20/cpp20.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#include <version>

int main() {}
4 changes: 4 additions & 0 deletions config.tests/cpp20/cpp20.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
CONFIG -= qt
CONFIG += c++2a

SOURCES = cpp20.cpp
13 changes: 13 additions & 0 deletions configtests.pri
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# configure style tests
# QMAKE_CONFIG_TESTS_DIR defaults to dir of current .pro files + config.tests
# sets config_$test if successful, e.g. config_cpp11 for test config.tests/cpp11

load(configure)

log("Running configure tests...$$escape_expand(\\n)")
CONFIG_TESTS = $$files($$QMAKE_CONFIG_TESTS_DIR/*.pro, true)
for(test, CONFIG_TESTS) {
test = $$basename(test)
test ~= s/\\.pro$//
qtCompileTest($$test)
}
6 changes: 6 additions & 0 deletions cpp/duplicatetracker/tests/duplicatetracker/cxx20/cxx20.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
CONFIG += testcase moc
TARGET = tst_duplicatetracker_20
QT = core testlib
CONFIG += c++2a
SOURCES += $$PWD/../tst_duplicatetracker.cpp
INCLUDEPATH += ../../../include
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ TEMPLATE = subdirs
SUBDIRS += \
cxx11 \
cxx17 \

config_cpp20:SUBDIRS += \
cxx20 \
6 changes: 6 additions & 0 deletions cpp/future-backports/tests/k20/erase_if/cxx11/cxx11.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
CONFIG += testcase
TARGET = tst_erase_if_11
QT = core testlib
CONFIG += c++11
SOURCES += ../tst_erase_if.cpp
INCLUDEPATH += ../../../../include
6 changes: 6 additions & 0 deletions cpp/future-backports/tests/k20/erase_if/cxx14/cxx14.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
CONFIG += testcase
TARGET = tst_erase_if_14
QT = core testlib
CONFIG += c++14
SOURCES += ../tst_erase_if.cpp
INCLUDEPATH += ../../../../include
6 changes: 6 additions & 0 deletions cpp/future-backports/tests/k20/erase_if/cxx17/cxx17.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
CONFIG += testcase
TARGET = tst_erase_if_17
QT = core testlib
CONFIG += c++1z
SOURCES += ../tst_erase_if.cpp
INCLUDEPATH += ../../../../include
6 changes: 6 additions & 0 deletions cpp/future-backports/tests/k20/erase_if/cxx20/cxx20.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
CONFIG += testcase
TARGET = tst_erase_if_20
QT = core testlib
CONFIG += c++2a
SOURCES += ../tst_erase_if.cpp
INCLUDEPATH += ../../../../include
17 changes: 9 additions & 8 deletions cpp/future-backports/tests/k20/erase_if/erase_if.pro
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
CONFIG += testcase
TARGET = tst_erase_if
QT = core testlib
contains(QT_CONFIG, c++14):CONFIG *= c++14
contains(QT_CONFIG, c++1z):CONFIG *= c++1z
contains(QT_CONFIG, c++2a):CONFIG *= c++2a
SOURCES += tst_erase_if.cpp
INCLUDEPATH += ../../../include
TEMPLATE = subdirs

SUBDIRS += \
cxx11 \
cxx14 \
cxx17 \

config_cpp20:SUBDIRS += \
cxx20 \
2 changes: 1 addition & 1 deletion cpp/future-backports/tests/k20/erase_if/tst_erase_if.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ private Q_SLOTS:
const Container c = il;
{
Container copy = c;
QCOMPARE(k20::erase_if(copy, [&](const auto &e) { return e == v; }), expected);
QCOMPARE(k20::erase_if(copy, [&](const value_type<Container> &e) { return e == v; }), expected);
if (expected > 0)
QVERIFY(copy != c);
else
Expand Down
6 changes: 6 additions & 0 deletions qt/stringtokenizer/tests/qstringtokenizer/cxx11/cxx11.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
CONFIG += testcase
TARGET = tst_qstringtokenizer_11
QT = core testlib
CONFIG += c++11
SOURCES += ../tst_qstringtokenizer.cpp
INCLUDEPATH += ../../../include
6 changes: 6 additions & 0 deletions qt/stringtokenizer/tests/qstringtokenizer/cxx14/cxx14.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
CONFIG += testcase
TARGET = tst_qstringtokenizer_14
QT = core testlib
CONFIG += c++14
SOURCES += ../tst_qstringtokenizer.cpp
INCLUDEPATH += ../../../include
6 changes: 6 additions & 0 deletions qt/stringtokenizer/tests/qstringtokenizer/cxx17/cxx17.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
CONFIG += testcase
TARGET = tst_qstringtokenizer_17
QT = core testlib
CONFIG += c++1z
SOURCES += ../tst_qstringtokenizer.cpp
INCLUDEPATH += ../../../include
6 changes: 6 additions & 0 deletions qt/stringtokenizer/tests/qstringtokenizer/cxx20/cxx20.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
CONFIG += testcase
TARGET = tst_qstringtokenizer_20
QT = core testlib
CONFIG += c++2a
SOURCES += ../tst_qstringtokenizer.cpp
INCLUDEPATH += ../../../include
17 changes: 9 additions & 8 deletions qt/stringtokenizer/tests/qstringtokenizer/qstringtokenizer.pro
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
CONFIG += testcase
TARGET = tst_qstringtokenizer
QT = core testlib
contains(QT_CONFIG, c++14):CONFIG *= c++14
contains(QT_CONFIG, c++1z):CONFIG *= c++1z
contains(QT_CONFIG, c++2a):CONFIG *= c++2a
SOURCES += tst_qstringtokenizer.cpp
INCLUDEPATH += ../../include
TEMPLATE = subdirs

SUBDIRS += \
cxx11 \
cxx14 \
cxx17 \

config_cpp20:SUBDIRS += \
cxx20 \

0 comments on commit 30801e4

Please sign in to comment.