[gobject-introspection/wip/smcv/test-more-flags: 3/3] girmarshalling tests: Diagnose GValue not holding enum/flags




commit ae2952e6167be60663d587a605e38e97d5f4978c
Author: Simon McVittie <smcv debian org>
Date:   Sun Aug 23 18:34:04 2020 +0100

    girmarshalling tests: Diagnose GValue not holding enum/flags
    
    If g_value_get_enum() or g_value_get_flags() is about to fail with a
    precondition check failure, we can improve diagnostics by issuing
    a more informative critical warning.
    
    Signed-off-by: Simon McVittie <smcv debian org>

 tests/gimarshallingtests.c | 4 ++++
 1 file changed, 4 insertions(+)
---
diff --git a/tests/gimarshallingtests.c b/tests/gimarshallingtests.c
index 571b7a2e2..483fb619f 100644
--- a/tests/gimarshallingtests.c
+++ b/tests/gimarshallingtests.c
@@ -3445,6 +3445,8 @@ gi_marshalling_tests_gvalue_in_with_modification (GValue *value)
 void
 gi_marshalling_tests_gvalue_in_enum (GValue *value)
 {
+  if (!G_VALUE_HOLDS_ENUM (value))
+    g_critical ("Expected enum, got %s", G_VALUE_TYPE_NAME (value));
   g_assert (g_value_get_enum (value) == GI_MARSHALLING_TESTS_ENUM_VALUE3);
 }
 
@@ -3455,6 +3457,8 @@ gi_marshalling_tests_gvalue_in_enum (GValue *value)
 void
 gi_marshalling_tests_gvalue_in_flags (GValue *value)
 {
+  if (!G_VALUE_HOLDS_FLAGS (value))
+    g_critical ("Expected flags, got %s", G_VALUE_TYPE_NAME (value));
   g_assert_cmpint (g_value_get_flags (value), ==, GI_MARSHALLING_TESTS_FLAGS_VALUE3);
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]