From d805b9ae511b61af6f3fb2d26a4bd2b4d6ef3253 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Sun, 24 Oct 2021 21:30:32 +0200 Subject: [PATCH] libnm/tests: always check expected default value for string properties in test_setting_metadata() --- src/libnm-core-impl/tests/test-setting.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/libnm-core-impl/tests/test-setting.c b/src/libnm-core-impl/tests/test-setting.c index 7b8a5ba494..e263b2143a 100644 --- a/src/libnm-core-impl/tests/test-setting.c +++ b/src/libnm-core-impl/tests/test-setting.c @@ -4647,19 +4647,19 @@ check_done:; g_object_get_property(G_OBJECT(setting), sip->name, &val); if (sip->param_spec->value_type == G_TYPE_STRING) { + const char *exp_default_value = NULL; const char *default_value; default_value = ((const GParamSpecString *) sip->param_spec)->default_value; - if (default_value) { - /* having a string property with a default != NULL is really ugly. They - * should be best avoided... */ - if (meta_type == NM_META_SETTING_TYPE_DCB - && nm_streq(sip->name, NM_SETTING_DCB_APP_FCOE_MODE)) { - /* Whitelist the properties that have a non-NULL default value. */ - g_assert_cmpstr(default_value, ==, NM_SETTING_DCB_FCOE_MODE_FABRIC); - } else - g_assert_not_reached(); + + /* having a string property with a default != NULL is really ugly. They + * should be best avoided... Only one property is known to have a non-NULL + * default. Assert that this stays. */ + if (meta_type == NM_META_SETTING_TYPE_DCB + && nm_streq(sip->name, NM_SETTING_DCB_APP_FCOE_MODE)) { + exp_default_value = NM_SETTING_DCB_FCOE_MODE_FABRIC; } + g_assert_cmpstr(default_value, ==, exp_default_value); if (nm_streq(sip->name, NM_SETTING_NAME)) g_assert_cmpstr(g_value_get_string(&val), ==, msi->setting_name);