t/: add test case for Issue #129 from Oleg Efimov

This commit is contained in:
Oleg Efimov 2014-03-22 21:40:02 +04:00 committed by Robert Edmonds
parent d2658e25fe
commit 9c7f8ce798
2 changed files with 30 additions and 0 deletions

View File

@ -1406,6 +1406,27 @@ test_optional_default_values (void)
foo__default_optional_values__free_unpacked (mess2, NULL); foo__default_optional_values__free_unpacked (mess2, NULL);
} }
static void
assert_optional_lowercase_enum_default_value_is_default (Foo__LowerCase *mess)
{
assert (!mess->has_value);
assert (mess->value == 2);
}
static void
test_optional_lowercase_enum_default_value (void)
{
Foo__LowerCase mess = FOO__LOWER_CASE__INIT;
Foo__LowerCase *mess2;
size_t len; uint8_t *data;
assert_optional_lowercase_enum_default_value_is_default (&mess);
mess2 = test_compare_pack_methods (&mess.base, &len, &data);
assert (len == 0); /* no non-default values */
free (data);
assert_optional_lowercase_enum_default_value_is_default (mess2);
foo__lower_case__free_unpacked (mess2, NULL);
}
static void static void
test_field_merge (void) test_field_merge (void)
{ {
@ -1672,6 +1693,8 @@ static Test tests[] =
{ "test required default values", test_required_default_values }, { "test required default values", test_required_default_values },
{ "test optional default values", test_optional_default_values }, { "test optional default values", test_optional_default_values },
{ "test optional lowercase enum default value", test_optional_lowercase_enum_default_value },
{ "test field merge", test_field_merge }, { "test field merge", test_field_merge },
{ "test free unpacked", test_alloc_free_all }, { "test free unpacked", test_alloc_free_all },

View File

@ -207,6 +207,13 @@ message DefaultOptionalValues {
optional string v_string = 7 [default = "hi mom\n"]; optional string v_string = 7 [default = "hi mom\n"];
optional bytes v_bytes = 8 [default = "a \0 character"]; optional bytes v_bytes = 8 [default = "a \0 character"];
} }
message LowerCase {
enum CaseEnum {
UPPER = 1;
lower = 2;
}
optional CaseEnum value = 1 [default = lower];
}
message AllocValues { message AllocValues {
optional bytes o_bytes = 1; optional bytes o_bytes = 1;
repeated string r_string = 2; repeated string r_string = 2;