Fix WriteXZYPosition64 and add tests
This commit is contained in:
parent
77a44e8dce
commit
b14874978a
@ -788,7 +788,7 @@ bool cByteBuffer::WriteXZYPosition64(Int32 a_BlockX, Int32 a_BlockY, Int32 a_Blo
|
|||||||
CheckValid();
|
CheckValid();
|
||||||
return WriteBEInt64(
|
return WriteBEInt64(
|
||||||
(static_cast<Int64>(a_BlockX & 0x3FFFFFF) << 38) |
|
(static_cast<Int64>(a_BlockX & 0x3FFFFFF) << 38) |
|
||||||
(static_cast<Int64>(a_BlockZ & 0x3FFFFFF) << 26) |
|
(static_cast<Int64>(a_BlockZ & 0x3FFFFFF) << 12) |
|
||||||
(static_cast<Int64>(a_BlockY & 0xFFF))
|
(static_cast<Int64>(a_BlockY & 0xFFF))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -70,8 +70,40 @@ static void TestWrap(void)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static void TestXYZPositionRoundtrip(void)
|
||||||
|
{
|
||||||
|
cByteBuffer buf(50);
|
||||||
|
buf.WriteXYZPosition64(-33554432, -2048, -33554432); // Testing the minimun values
|
||||||
|
int x, y, z;
|
||||||
|
TEST_TRUE(buf.ReadXYZPosition64(x, y, z));
|
||||||
|
TEST_EQUAL(x, -33554432);
|
||||||
|
TEST_EQUAL(y, -2048);
|
||||||
|
TEST_EQUAL(z, -33554432);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static void TestXZYPositionRoundtrip(void)
|
||||||
|
{
|
||||||
|
cByteBuffer buf(50);
|
||||||
|
buf.WriteXZYPosition64(-33554432, -2048, -33554432); // Testing the minimun values
|
||||||
|
int x, y, z;
|
||||||
|
TEST_TRUE(buf.ReadXZYPosition64(x, y, z));
|
||||||
|
TEST_EQUAL(x, -33554432);
|
||||||
|
TEST_EQUAL(y, -2048);
|
||||||
|
TEST_EQUAL(z, -33554432);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
IMPLEMENT_TEST_MAIN("ByteBuffer",
|
IMPLEMENT_TEST_MAIN("ByteBuffer",
|
||||||
TestRead();
|
TestRead();
|
||||||
TestWrite();
|
TestWrite();
|
||||||
TestWrap();
|
TestWrap();
|
||||||
|
TestXYZPositionRoundtrip();
|
||||||
|
TestXZYPositionRoundtrip();
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user