mirror of
https://github.com/protobuf-c/protobuf-c.git
synced 2024-12-26 21:04:23 +08:00
test-generated-code2.c: Add default value test
This commit is contained in:
parent
258eb7d4dc
commit
2ea8fc7087
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user