From 5596ba9efa6de9bb4e14dc3d43cc16b6d78a4188 Mon Sep 17 00:00:00 2001 From: Max Wittal Date: Tue, 29 Oct 2024 19:23:23 +0700 Subject: [PATCH] write_bytes() tests --- test/mmx_tests.cpp | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/test/mmx_tests.cpp b/test/mmx_tests.cpp index 53b89c59a..c4cfa7873 100644 --- a/test/mmx_tests.cpp +++ b/test/mmx_tests.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include @@ -233,6 +234,47 @@ int main(int argc, char** argv) } VNX_TEST_END() + VNX_TEST_BEGIN("write_bytes()") + { + { + const bool value = true; + std::vector tmp; + vnx::VectorOutputStream stream(&tmp); + vnx::OutputBuffer out(&stream); + write_bytes(out, value); + out.flush(); + vnx::test::expect(tmp.size(), 1u); + } + { + const vnx::Variant value(true); + std::vector tmp; + vnx::VectorOutputStream stream(&tmp); + vnx::OutputBuffer out(&stream); + write_bytes(out, value); + out.flush(); + vnx::test::expect(tmp.size(), 1u); + } + { + const vnx::Variant value(1337); + std::vector tmp; + vnx::VectorOutputStream stream(&tmp); + vnx::OutputBuffer out(&stream); + write_bytes(out, value); + out.flush(); + vnx::test::expect(tmp.size(), 8u); + } + { + const vnx::Variant value(-1337); + std::vector tmp; + vnx::VectorOutputStream stream(&tmp); + vnx::OutputBuffer out(&stream); + write_bytes(out, value); + out.flush(); + vnx::test::expect(tmp.size(), 8u); + } + } + VNX_TEST_END() + return vnx::test::done(); }