Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
protobuf-c
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
protobuf-c
Commits
3fccff93
Commit
3fccff93
authored
Apr 03, 2014
by
Robert Edmonds
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
t/: add test case test_field_flags
parent
e9627054
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
0 deletions
+47
-0
t/generated-code2/test-generated-code2.c
t/generated-code2/test-generated-code2.c
+38
-0
t/test-full.proto
t/test-full.proto
+9
-0
No files found.
t/generated-code2/test-generated-code2.c
View file @
3fccff93
...
...
@@ -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))
...
...
t/test-full.proto
View file @
3fccff93
...
...
@@ -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
];
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment