[glib: 5/7] glib/tests/cxx: Enable the c++ tests for all the C++ versions
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib: 5/7] glib/tests/cxx: Enable the c++ tests for all the C++ versions
- Date: Wed, 12 Oct 2022 09:56:27 +0000 (UTC)
commit c19904d6e8951ea774dc298fa793d8b0e506e32d
Author: Marco Trevisan (Treviño) <mail 3v1n0 net>
Date: Tue Sep 13 18:44:45 2022 +0200
glib/tests/cxx: Enable the c++ tests for all the C++ versions
We should support these macros everywhere, if not, we should fix them
again.
glib/tests/cxx.cpp | 39 +++++++++------------------------------
1 file changed, 9 insertions(+), 30 deletions(-)
---
diff --git a/glib/tests/cxx.cpp b/glib/tests/cxx.cpp
index d3ec77b2a2..6ac60791c8 100644
--- a/glib/tests/cxx.cpp
+++ b/glib/tests/cxx.cpp
@@ -27,9 +27,6 @@ typedef struct
static void
test_typeof (void)
{
-#if __cplusplus >= 201103L
- // Test that with C++11 we don't get those kind of errors:
- // error: invalid conversion from ‘gpointer’ {aka ‘void*’} to ‘MyObject*’ [-fpermissive]
MyObject *obj = g_rc_box_new0 (MyObject);
MyObject *obj2 = g_rc_box_acquire (obj);
g_assert_true (obj2 == obj);
@@ -37,12 +34,21 @@ test_typeof (void)
MyObject *obj3 = g_atomic_pointer_get (&obj2);
g_assert_true (obj3 == obj);
+#if __cplusplus >= 201103L
MyObject *obj4 = nullptr;
+#else
+ MyObject *obj4 = NULL;
+#endif
g_atomic_pointer_set (&obj4, obj3);
g_assert_true (obj4 == obj);
+#if __cplusplus >= 201103L
MyObject *obj5 = nullptr;
g_atomic_pointer_compare_and_exchange (&obj5, nullptr, obj4);
+#else
+ MyObject *obj5 = NULL;
+ g_atomic_pointer_compare_and_exchange (&obj5, NULL, obj4);
+#endif
g_assert_true (obj5 == obj);
MyObject *obj6 = g_steal_pointer (&obj5);
@@ -50,15 +56,11 @@ test_typeof (void)
g_clear_pointer (&obj6, g_rc_box_release);
g_rc_box_release (obj);
-#else
- g_test_skip ("This test requires a C++11 compiler");
-#endif
}
static void
test_atomic_pointer_compare_and_exchange (void)
{
-#if __cplusplus >= 201103L
const gchar *str1 = "str1";
const gchar *str2 = "str2";
const gchar *atomic_string = str1;
@@ -68,15 +70,11 @@ test_atomic_pointer_compare_and_exchange (void)
g_assert_true (g_atomic_pointer_compare_and_exchange (&atomic_string, str1, str2));
g_assert_true (atomic_string == str2);
-#else
- g_test_skip ("This test requires a C++11 compiler");
-#endif
}
static void
test_atomic_pointer_compare_and_exchange_full (void)
{
-#if __cplusplus >= 201103L
const gchar *str1 = "str1";
const gchar *str2 = "str2";
const gchar *atomic_string = str1;
@@ -88,15 +86,11 @@ test_atomic_pointer_compare_and_exchange_full (void)
g_assert_true (g_atomic_pointer_compare_and_exchange_full (&atomic_string, str1, str2, &old));
g_assert_true (atomic_string == str2);
g_assert_true (old == str1);
-#else
- g_test_skip ("This test requires a C++11 compiler");
-#endif
}
static void
test_atomic_int_compare_and_exchange (void)
{
-#if __cplusplus >= 201103L
gint atomic_int = 5;
g_test_message ("Test that g_atomic_int_compare_and_exchange() doesn’t have "
@@ -104,15 +98,11 @@ test_atomic_int_compare_and_exchange (void)
g_assert_true (g_atomic_int_compare_and_exchange (&atomic_int, 5, 50));
g_assert_cmpint (atomic_int, ==, 50);
-#else
- g_test_skip ("This test requires a C++11 compiler");
-#endif
}
static void
test_atomic_int_compare_and_exchange_full (void)
{
-#if __cplusplus >= 201103L
gint atomic_int = 5;
gint old_value;
@@ -122,15 +112,11 @@ test_atomic_int_compare_and_exchange_full (void)
g_assert_true (g_atomic_int_compare_and_exchange_full (&atomic_int, 5, 50, &old_value));
g_assert_cmpint (atomic_int, ==, 50);
g_assert_cmpint (old_value, ==, 5);
-#else
- g_test_skip ("This test requires a C++11 compiler");
-#endif
}
static void
test_atomic_pointer_exchange (void)
{
-#if __cplusplus >= 201103L
const gchar *str1 = "str1";
const gchar *str2 = "str2";
const gchar *atomic_string = str1;
@@ -140,24 +126,17 @@ test_atomic_pointer_exchange (void)
g_assert_true (g_atomic_pointer_exchange (&atomic_string, str2) == str1);
g_assert_true (atomic_string == str2);
-#else
- g_test_skip ("This test requires a C++11 compiler");
-#endif
}
static void
test_atomic_int_exchange (void)
{
-#if __cplusplus >= 201103L
gint atomic_int = 5;
g_test_message ("Test that g_atomic_int_compare_and_exchange() doesn’t have "
"any compiler warnings in C++ mode");
g_assert_cmpint (g_atomic_int_exchange (&atomic_int, 50), ==, 5);
-#else
- g_test_skip ("This test requires a C++11 compiler");
-#endif
}
G_NO_INLINE
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]