mirror of
https://github.com/protobuf-c/protobuf-c.git
synced 2024-12-26 21:04:23 +08:00
Add test case for #330
This commit is contained in:
parent
9412830d06
commit
6aa7dc7a10
17
Makefile.am
17
Makefile.am
@ -250,6 +250,23 @@ BUILT_SOURCES += \
|
||||
EXTRA_DIST += \
|
||||
t/issue251/issue251.proto
|
||||
|
||||
# Issue #330
|
||||
check_PROGRAMS += \
|
||||
t/issue330/issue330
|
||||
TESTS += \
|
||||
t/issue330/issue330
|
||||
t_issue330_issue330_SOURCES = \
|
||||
t/issue330/issue330.c \
|
||||
t/issue330/issue330.pb-c.c
|
||||
t_issue330_issue330_LDADD = \
|
||||
protobuf-c/libprotobuf-c.la
|
||||
t/issue330/issue330.pb-c.c t/issue330/issue330.pb-c.h: $(top_builddir)/protoc-c/protoc-gen-c$(EXEEXT) $(top_srcdir)/t/issue330/issue330.proto
|
||||
$(AM_V_GEN)@PROTOC@ --plugin=protoc-gen-c=$(top_builddir)/protoc-c/protoc-gen-c$(EXEEXT) -I$(top_srcdir) --c_out=$(top_builddir) $(top_srcdir)/t/issue330/issue330.proto
|
||||
BUILT_SOURCES += \
|
||||
t/issue330/issue330.pb-c.c t/issue330/issue330.pb-c.h
|
||||
EXTRA_DIST += \
|
||||
t/issue330/issue330.proto
|
||||
|
||||
endif # CROSS_COMPILING
|
||||
|
||||
endif # BUILD_COMPILER
|
||||
|
1
t/issue330/.gitignore
vendored
Normal file
1
t/issue330/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
issue330
|
25
t/issue330/issue330.c
Normal file
25
t/issue330/issue330.c
Normal file
@ -0,0 +1,25 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "t/issue330/issue330.pb-c.h"
|
||||
|
||||
int main(void)
|
||||
{
|
||||
/* Output of $ echo acl_id: 2 acl_id: 3 | protoc issue330.proto \
|
||||
* --encode=pbr_route | xxd -i: 0x52, 0x02, 0x02, 0x03
|
||||
*/
|
||||
uint8_t protoc[] = {0x52, 0x02, 0x02, 0x03};
|
||||
PbrRoute msg = PBR_ROUTE__INIT;
|
||||
int ids[] = {2, 3};
|
||||
uint8_t buf[16] = {0};
|
||||
size_t sz = 0;
|
||||
|
||||
msg.n_acl_id = 2;
|
||||
msg.acl_id = ids;
|
||||
sz = pbr_route__pack(&msg, buf);
|
||||
|
||||
assert (sz == sizeof protoc);
|
||||
assert (memcmp (protoc, buf, sz) == 0);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
5
t/issue330/issue330.proto
Normal file
5
t/issue330/issue330.proto
Normal file
@ -0,0 +1,5 @@
|
||||
syntax = "proto3";
|
||||
|
||||
message pbr_route {
|
||||
repeated int32 acl_id = 10;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user