summaryrefslogtreecommitdiffstats
path: root/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp')
-rw-r--r--tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp b/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp
index 204758f68a..9ada718682 100644
--- a/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp
+++ b/tests/auto/testlib/selftests/cmptest/tst_cmptest.cpp
@@ -128,6 +128,7 @@ private slots:
void compare_registered_enums();
void compare_class_enums();
void compare_boolfuncs();
+ void compare_to_nullptr();
void compare_pointerfuncs();
void compare_tostring();
void compare_tostring_data();
@@ -180,6 +181,24 @@ void tst_Cmptest::compare_boolfuncs()
QCOMPARE(!boolfunc(), false);
}
+namespace {
+template <typename T>
+T *null() Q_DECL_NOTHROW { return nullptr; }
+}
+
+void tst_Cmptest::compare_to_nullptr()
+{
+ QCOMPARE(null<int>(), nullptr);
+ QCOMPARE(null<const int>(), nullptr);
+ QCOMPARE(null<volatile int>(), nullptr);
+ QCOMPARE(null<const volatile int>(), nullptr);
+
+ QCOMPARE(nullptr, null<int>());
+ QCOMPARE(nullptr, null<const int>());
+ QCOMPARE(nullptr, null<volatile int>());
+ QCOMPARE(nullptr, null<const volatile int>());
+}
+
static int i = 0;
static int *intptr() { return &i; }