From 2edc9c6fd10e34ca1da0d25d3ceb9b67a6b9c73c Mon Sep 17 00:00:00 2001 From: Přemysl Eric Janouch Date: Fri, 7 Jul 2023 12:25:14 +0200 Subject: Add a C++ backend for LibertyXDR Also change the C backend so that it also de/serializes unions without any other fields besides the tag. --- tests/lxdrgen.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'tests/lxdrgen.c') diff --git a/tests/lxdrgen.c b/tests/lxdrgen.c index 14f40e2..78ec47b 100644 --- a/tests/lxdrgen.c +++ b/tests/lxdrgen.c @@ -53,6 +53,10 @@ test_ser_deser_free (void) u->others.bar = str_make (); for (int i = rand () % 0x30; i > 0; i--) str_append_c (&u->others.bar, 0x30 + i); + u->others.baz_len = rand () % 0x30; + u->others.baz = xcalloc (1, u->others.baz_len); + for (uint32_t i = 0; i < u->others.baz_len; i++) + u->others.baz[i] = 0x30 + i; break; case 2: u->tag = PROTO_GEN_ENUM_NOTHING; @@ -62,6 +66,8 @@ test_ser_deser_free (void) } } + a.o.tag = PROTO_GEN_ENUM_NOTHING; + struct str buf = str_make (); hard_assert (proto_gen_struct_serialize (&a, &buf)); struct msg_unpacker r = msg_unpacker_make (buf.str, buf.len); @@ -92,6 +98,9 @@ test_ser_deser_free (void) hard_assert (ua->others.bar.len == ub->others.bar.len); hard_assert (!memcmp (ua->others.bar.str, ub->others.bar.str, ua->others.bar.len)); + hard_assert (ua->others.baz_len == ub->others.baz_len); + hard_assert (!memcmp (ua->others.baz, ub->others.baz, + ua->others.baz_len)); break; case PROTO_GEN_ENUM_NOTHING: break; @@ -100,6 +109,8 @@ test_ser_deser_free (void) } } + hard_assert (a.o.tag == b.o.tag); + // Emulate partially deserialized data to test disposal of that. for (size_t i = b.u_len - CASES; i < b.u_len; i++) { -- cgit v1.2.3-70-g09d2