mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 18:41:51 +00:00
update byte_utils
This commit is contained in:
parent
3d3679c8b1
commit
0b3bb36188
5 changed files with 88 additions and 68 deletions
20
test/coders/byte_utils.cpp
Normal file
20
test/coders/byte_utils.cpp
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
#include <gtest/gtest.h>
|
||||
|
||||
#include "coders/byte_utils.hpp"
|
||||
|
||||
TEST(byte_utils, BytesBuildAndRead) {
|
||||
ByteBuilder builder;
|
||||
builder.putCStr("MAGIC.#");
|
||||
builder.put(50);
|
||||
builder.putInt16(1980);
|
||||
builder.putInt32(123456789);
|
||||
builder.putInt64(98765432123456789LL);
|
||||
auto data = builder.build();
|
||||
|
||||
ByteReader reader(data.data(), data.size());
|
||||
reader.checkMagic("MAGIC.#", 8);
|
||||
EXPECT_EQ(reader.get(), 50);
|
||||
EXPECT_EQ(reader.getInt16(), 1980);
|
||||
EXPECT_EQ(reader.getInt32(), 123456789);
|
||||
EXPECT_EQ(reader.getInt64(), 98765432123456789LL);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue