[Yunq] Add serialization tests for Types message.

This commit is contained in:
Drew Galbraith 2024-01-17 14:15:53 -08:00
parent 3114ac110a
commit a98e66ac47
2 changed files with 19 additions and 1 deletions

View File

@ -15,7 +15,7 @@ add_dependencies(build_test
yunq_test)
# Build the yunq manualy rather than using the generator
# Build the yunq manually rather than using the generator
# because we don't want to link against mammoth and overrite new.
set(target example_yunq)
add_library(example_yunq

View File

@ -32,3 +32,21 @@ TEST_CASE("Types Setter/Getter", "[yunq]") {
REQUIRE(t.signed_int() == -1);
REQUIRE(t.str() == "test");
}
TEST_CASE("Types Serialization", "[yunq]") {
ex::Types a;
a.set_unsigned_int(1);
a.set_signed_int(-1);
a.set_str("test");
glcr::ByteBuffer buf(1024);
a.SerializeToBytes(buf, 0);
ex::Types b;
yunq::MessageView v(buf, 0);
REQUIRE(b.ParseFromBytes(v).ok() == true);
REQUIRE(b.unsigned_int() == 1);
REQUIRE(b.signed_int() == -1);
REQUIRE(b.str() == "test");
}