Commit 3fccff93 authored by Robert Edmonds's avatar Robert Edmonds

t/: add test case test_field_flags

parent e9627054
......@@ -1612,6 +1612,42 @@ static void test_required_fields_bitmap(void)
assert (msg == NULL);
}
static void
test_field_flags (void)
{
const ProtobufCFieldDescriptor *f;
f = protobuf_c_message_descriptor_get_field_by_name(
&foo__test_field_flags__descriptor, "no_flags1");
assert(f != NULL);
assert(!(f->flags & PROTOBUF_C_FIELD_FLAG_PACKED));
assert(!(f->flags & PROTOBUF_C_FIELD_FLAG_DEPRECATED));
f = protobuf_c_message_descriptor_get_field_by_name(
&foo__test_field_flags__descriptor, "no_flags2");
assert(f != NULL);
assert(!(f->flags & PROTOBUF_C_FIELD_FLAG_PACKED));
assert(!(f->flags & PROTOBUF_C_FIELD_FLAG_DEPRECATED));
f = protobuf_c_message_descriptor_get_field_by_name(
&foo__test_field_flags__descriptor, "no_flags3");
assert(f != NULL);
assert(!(f->flags & PROTOBUF_C_FIELD_FLAG_PACKED));
assert(!(f->flags & PROTOBUF_C_FIELD_FLAG_DEPRECATED));
f = protobuf_c_message_descriptor_get_field_by_name(
&foo__test_field_flags__descriptor, "packed");
assert(f != NULL);
assert((f->flags & PROTOBUF_C_FIELD_FLAG_PACKED));
assert(!(f->flags & PROTOBUF_C_FIELD_FLAG_DEPRECATED));
f = protobuf_c_message_descriptor_get_field_by_name(
&foo__test_field_flags__descriptor, "packed_deprecated");
assert(f != NULL);
assert((f->flags & PROTOBUF_C_FIELD_FLAG_PACKED));
assert((f->flags & PROTOBUF_C_FIELD_FLAG_DEPRECATED));
}
/* === simple testing framework === */
typedef void (*TestFunc) (void);
......@@ -1718,6 +1754,8 @@ static Test tests[] =
{ "test alloc failure", test_alloc_fail },
{ "test required_fields_bitmap", test_required_fields_bitmap },
{ "test field flags", test_field_flags },
};
#define n_tests (sizeof(tests)/sizeof(Test))
......
......@@ -353,3 +353,12 @@ message TestRequiredFieldsBitmap {
optional string field128 = 128;
required string field129 = 129;
}
message TestFieldFlags {
optional int32 no_flags1 = 1;
required int32 no_flags2 = 2;
repeated int32 no_flags3 = 3;
repeated int32 packed = 4 [packed=true];
repeated int32 packed_deprecated = 5 [packed=true, deprecated=true];
repeated int32 deprecated = 6 [deprecated=true];
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment