From 42ca2dcef5b17ae15b63b316950673c9abdf94dd Mon Sep 17 00:00:00 2001 From: levlam Date: Thu, 18 Nov 2021 16:32:12 +0300 Subject: [PATCH] Add serialize test. --- tdutils/test/misc.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tdutils/test/misc.cpp b/tdutils/test/misc.cpp index b5c878ca1..5d4084561 100644 --- a/tdutils/test/misc.cpp +++ b/tdutils/test/misc.cpp @@ -35,6 +35,7 @@ #include "td/utils/StringBuilder.h" #include "td/utils/tests.h" #include "td/utils/Time.h" +#include "td/utils/tl_helpers.h" #include "td/utils/translit.h" #include "td/utils/uint128.h" #include "td/utils/unicode.h" @@ -1235,3 +1236,10 @@ TEST(Misc, is_emoji) { ASSERT_TRUE(td::is_emoji("❤️")); ASSERT_TRUE(td::is_emoji("❤")); } + +TEST(Misc, serialize) { + td::int32 x = 1; + ASSERT_EQ(td::base64_encode(td::serialize(x)), td::base64_encode(td::string("\x01\x00\x00\x00", 4))); + td::int64 y = -2; + ASSERT_EQ(td::base64_encode(td::serialize(y)), td::base64_encode(td::string("\xfe\xff\xff\xff\xff\xff\xff\xff", 8))); +}