diff options
author | Přemysl Eric Janouch <p@janouch.name> | 2023-07-07 12:25:14 +0200 |
---|---|---|
committer | Přemysl Eric Janouch <p@janouch.name> | 2023-07-07 16:43:52 +0200 |
commit | 2edc9c6fd10e34ca1da0d25d3ceb9b67a6b9c73c (patch) | |
tree | 83e3f3c9cd4b4200946ec2428672cecfd6d3d311 /tests/lxdrgen.c | |
parent | f78f8a70f1753d687cae4a23659995b65e91fb3e (diff) | |
download | liberty-2edc9c6fd10e34ca1da0d25d3ceb9b67a6b9c73c.tar.gz liberty-2edc9c6fd10e34ca1da0d25d3ceb9b67a6b9c73c.tar.xz liberty-2edc9c6fd10e34ca1da0d25d3ceb9b67a6b9c73c.zip |
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.
Diffstat (limited to 'tests/lxdrgen.c')
-rw-r--r-- | tests/lxdrgen.c | 11 |
1 files changed, 11 insertions, 0 deletions
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++) { |