[gobject-introspection/wip/smcv/test-more-flags: 3/3] girmarshalling tests: Diagnose GValue not holding enum/flags
- From: Simon McVittie <smcv src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gobject-introspection/wip/smcv/test-more-flags: 3/3] girmarshalling tests: Diagnose GValue not holding enum/flags
- Date: Sun, 23 Aug 2020 17:34:53 +0000 (UTC)
commit fd75088f7cfeef1df40bb9436a82d2bbf427323c
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 33903b15b..f1e004ff9 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 (g_value_get_flags (value) == GI_MARSHALLING_TESTS_FLAGS_VALUE3);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]