mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 10:31:50 +00:00
add util::Buffer, rle::encode16, rle::decode16
This commit is contained in:
parent
728795f0f3
commit
c15abfa715
7 changed files with 144 additions and 31 deletions
25
test/voxels/Chunk.cpp
Normal file
25
test/voxels/Chunk.cpp
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
#include <gtest/gtest.h>
|
||||
|
||||
#include "voxels/Chunk.hpp"
|
||||
|
||||
TEST(Chunk, EncodeDecode) {
|
||||
Chunk chunk1(0, 0);
|
||||
for (uint i = 0; i < CHUNK_VOL; i++) {
|
||||
chunk1.voxels[i].id = rand();
|
||||
chunk1.voxels[i].state.rotation = rand();
|
||||
chunk1.voxels[i].state.segment = rand();
|
||||
chunk1.voxels[i].state.userbits = rand();
|
||||
}
|
||||
auto bytes = chunk1.encode();
|
||||
|
||||
Chunk chunk2(0, 0);
|
||||
chunk2.decode(bytes.get());
|
||||
|
||||
for (uint i = 0; i < CHUNK_VOL; i++) {
|
||||
EXPECT_EQ(chunk1.voxels[i].id, chunk2.voxels[i].id);
|
||||
EXPECT_EQ(
|
||||
blockstate2int(chunk1.voxels[i].state),
|
||||
blockstate2int(chunk2.voxels[i].state)
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue