Add serialize test.

This commit is contained in:
levlam 2021-11-18 16:32:12 +03:00
parent 2b9b9f0c31
commit 42ca2dcef5

View File

@ -35,6 +35,7 @@
#include "td/utils/StringBuilder.h" #include "td/utils/StringBuilder.h"
#include "td/utils/tests.h" #include "td/utils/tests.h"
#include "td/utils/Time.h" #include "td/utils/Time.h"
#include "td/utils/tl_helpers.h"
#include "td/utils/translit.h" #include "td/utils/translit.h"
#include "td/utils/uint128.h" #include "td/utils/uint128.h"
#include "td/utils/unicode.h" #include "td/utils/unicode.h"
@ -1235,3 +1236,10 @@ TEST(Misc, is_emoji) {
ASSERT_TRUE(td::is_emoji("❤️")); ASSERT_TRUE(td::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)));
}