From a98e66ac475aca632e61ab88238bfe74d8b91307 Mon Sep 17 00:00:00 2001 From: Drew Galbraith Date: Wed, 17 Jan 2024 14:15:53 -0800 Subject: [PATCH] [Yunq] Add serialization tests for Types message. --- lib/yunq/test/CMakeLists.txt | 2 +- lib/yunq/test/yunq_test.cpp | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/lib/yunq/test/CMakeLists.txt b/lib/yunq/test/CMakeLists.txt index f05d41c..d33b8e2 100644 --- a/lib/yunq/test/CMakeLists.txt +++ b/lib/yunq/test/CMakeLists.txt @@ -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 diff --git a/lib/yunq/test/yunq_test.cpp b/lib/yunq/test/yunq_test.cpp index d2e79a5..ade34d9 100644 --- a/lib/yunq/test/yunq_test.cpp +++ b/lib/yunq/test/yunq_test.cpp @@ -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"); +}