From 2ea8fc7087a176435b9632b9862b3b4aedebcf12 Mon Sep 17 00:00:00 2001 From: Ilya Lipnitskiy Date: Fri, 22 Apr 2016 11:34:02 -0700 Subject: [PATCH] test-generated-code2.c: Add default value test --- t/generated-code2/test-generated-code2.c | 30 ++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/t/generated-code2/test-generated-code2.c b/t/generated-code2/test-generated-code2.c index 07ac0bc..c0cd36c 100644 --- a/t/generated-code2/test-generated-code2.c +++ b/t/generated-code2/test-generated-code2.c @@ -1721,6 +1721,33 @@ assert_optional_default_values_are_default (Foo__DefaultOptionalValues *mess) assert (memcmp (mess->v_bytes.data, "a \0 character", 13) == 0); } +static void +assert_unspecified_default_values_are_correct (Foo__TestMessOptional *mess) +{ + assert (!mess->has_test_int32); + assert (mess->test_int32 == 0); + assert (!mess->has_test_uint32); + assert (mess->test_uint32 == 0); + assert (!mess->has_test_int64); + assert (mess->test_int64 == 0); + assert (!mess->has_test_uint64); + assert (mess->test_uint64 == 0); + assert (!mess->has_test_float); + assert (mess->test_float == 0.0); + assert (!mess->has_test_double); + assert (mess->test_double == 0.0); + assert (mess->test_string == NULL); + assert (!mess->has_test_bytes); + assert (mess->test_bytes.len == 0); + assert (mess->test_bytes.data == NULL); + assert (!mess->has_test_boolean); + assert (!mess->test_boolean); + assert (!mess->has_test_enum_small); + assert (mess->test_enum_small == FOO__TEST_ENUM_SMALL__NEG_VALUE); + assert (!mess->has_test_enum); + assert (mess->test_enum == FOO__TEST_ENUM__VALUENEG123456); +} + static void test_optional_default_values (void) { @@ -1733,6 +1760,9 @@ test_optional_default_values (void) free (data); assert_optional_default_values_are_default (mess2); foo__default_optional_values__free_unpacked (mess2, NULL); + + Foo__TestMessOptional mess3 = FOO__TEST_MESS_OPTIONAL__INIT; + assert_unspecified_default_values_are_correct (&mess3); } static void