Create a message descriptor type.

This replaces the sentinel at the end of the pb_field_t
array for each message type.

git-svn-id: https://svn.kapsi.fi/jpa/nanopb-dev@1007 e3a754e5-d11d-0410-8d38-ebb782a927b9
This commit is contained in:
Michael Poole
2011-11-13 18:10:11 +00:00
committed by Petteri Aimonen
parent dcf43a6416
commit 43b8e20744
17 changed files with 127 additions and 101 deletions

View File

@@ -196,13 +196,13 @@ int main()
COMMENT("Test pb_encode with int32 array")
TEST(WRITES(pb_encode(&s, IntegerArray_fields, &msg), "\x0A\x05\x01\x02\x03\x04\x05"))
TEST(WRITES(pb_encode(&s, IntegerArray_msg, &msg), "\x0A\x05\x01\x02\x03\x04\x05"))
msg.data_count = 0;
TEST(WRITES(pb_encode(&s, IntegerArray_fields, &msg), ""))
TEST(WRITES(pb_encode(&s, IntegerArray_msg, &msg), ""))
msg.data_count = 10;
TEST(!pb_encode(&s, IntegerArray_fields, &msg))
TEST(!pb_encode(&s, IntegerArray_msg, &msg))
}
{
@@ -212,14 +212,14 @@ int main()
COMMENT("Test pb_encode with float array")
TEST(WRITES(pb_encode(&s, FloatArray_fields, &msg),
TEST(WRITES(pb_encode(&s, FloatArray_msg, &msg),
"\x0A\x04\x00\x00\xc6\x42"))
msg.data_count = 0;
TEST(WRITES(pb_encode(&s, FloatArray_fields, &msg), ""))
TEST(WRITES(pb_encode(&s, FloatArray_msg, &msg), ""))
msg.data_count = 3;
TEST(!pb_encode(&s, FloatArray_fields, &msg))
TEST(!pb_encode(&s, FloatArray_msg, &msg))
}
{
@@ -230,7 +230,7 @@ int main()
msg.data.funcs.encode = &fieldcallback;
COMMENT("Test pb_encode with callback field.")
TEST(WRITES(pb_encode(&s, CallbackArray_fields, &msg), "\x08\x55"))
TEST(WRITES(pb_encode(&s, CallbackArray_msg, &msg), "\x08\x55"))
}
{
@@ -239,7 +239,7 @@ int main()
IntegerContainer msg = {{5, {1,2,3,4,5}}};
COMMENT("Test pb_encode with packed array in a submessage.")
TEST(WRITES(pb_encode(&s, IntegerContainer_fields, &msg),
TEST(WRITES(pb_encode(&s, IntegerContainer_msg, &msg),
"\x0A\x07\x0A\x05\x01\x02\x03\x04\x05"))
}
@@ -254,8 +254,8 @@ int main()
msg2.submsg.submsg.data.funcs.encode = &fieldcallback;
COMMENT("Test pb_encode with callback field in a submessage.")
TEST(WRITES(pb_encode(&s, CallbackContainer_fields, &msg), "\x0A\x02\x08\x55"))
TEST(WRITES(pb_encode(&s, CallbackContainerContainer_fields, &msg2),
TEST(WRITES(pb_encode(&s, CallbackContainer_msg, &msg), "\x0A\x02\x08\x55"))
TEST(WRITES(pb_encode(&s, CallbackContainerContainer_msg, &msg2),
"\x0A\x04\x0A\x02\x08\x55"))
/* Misbehaving callback: varying output between calls */
@@ -264,9 +264,9 @@ int main()
msg2.submsg.submsg.data.funcs.encode = &crazyfieldcallback;
msg2.submsg.submsg.data.arg = &state;
TEST(!pb_encode(&s, CallbackContainer_fields, &msg))
TEST(!pb_encode(&s, CallbackContainer_msg, &msg))
state = 1;
TEST(!pb_encode(&s, CallbackContainerContainer_fields, &msg2))
TEST(!pb_encode(&s, CallbackContainerContainer_msg, &msg2))
}
if (status != 0)