From 868cd94ee9a5a0638c014a4cc42224f01ff234c8 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Fri, 5 Mar 2021 13:03:55 +0000 Subject: Prepare ChunkData for BlockState storage (#5105) * Rename ChunkData Creatable test * Add missing Y-check in RedstoneWireHandler * Remove ChunkDef.h dependency in Scoreboard * Prepare ChunkData for BlockState storage + Split chunk block, meta, block & sky light storage + Load the height map from disk - Reduce duplicated code in ChunkData - Remove saving MCSBiomes, there aren't any - Remove the allocation pool, ref #4315, #3864 * fixed build * fixed test * fixed the debug compile Co-authored-by: 12xx12 <44411062+12xx12@users.noreply.github.com> --- tests/ChunkData/CopyBlocks.cpp | 98 ------------------------------------------ 1 file changed, 98 deletions(-) delete mode 100644 tests/ChunkData/CopyBlocks.cpp (limited to 'tests/ChunkData/CopyBlocks.cpp') diff --git a/tests/ChunkData/CopyBlocks.cpp b/tests/ChunkData/CopyBlocks.cpp deleted file mode 100644 index c86a9e754..000000000 --- a/tests/ChunkData/CopyBlocks.cpp +++ /dev/null @@ -1,98 +0,0 @@ - -// CopyBlocks.cpp - -// Implements the test for cChunkData::CopyBlockTypes() range copying - - - - - -#include "Globals.h" -#include "../TestHelpers.h" -#include "ChunkData.h" - - - - - -/** Performs the entire CopyBlocks test. */ -static void test() -{ - // Set up a cChunkData with known contents - all blocks 0x01, all metas 0x02: - class cMockAllocationPool - : public cAllocationPool - { - virtual cChunkData::sChunkSection * Allocate() override - { - return new cChunkData::sChunkSection(); - } - - virtual void Free(cChunkData::sChunkSection * a_Ptr) override - { - delete a_Ptr; - } - - virtual bool DoIsEqual(const cAllocationPool &) const noexcept override - { - return false; - } - } Pool; - cChunkData Data(Pool); - cChunkDef::BlockTypes BlockTypes; - cChunkDef::BlockNibbles BlockMetas; - memset(BlockTypes, 0x01, sizeof(BlockTypes)); - memset(BlockMetas, 0x02, sizeof(BlockMetas)); - Data.SetBlockTypes(BlockTypes); - Data.SetMetas(BlockMetas); - - // Try to read varying amounts of blocktypes from the cChunkData. - // Verify that the exact amount of memory is copied, by copying to a larger buffer and checking its boundaries - BLOCKTYPE TestBuffer[5 * cChunkDef::NumBlocks]; - size_t WritePosIdx = 2 * cChunkDef::NumBlocks; - BLOCKTYPE * WritePosition = &TestBuffer[WritePosIdx]; - memset(TestBuffer, 0x03, sizeof(TestBuffer)); - size_t LastReportedStep = 1; - for (size_t idx = 0; idx < 5000; idx += 73) - { - if (idx / 500 != LastReportedStep) - { - printf("Testing index %u...\n", static_cast(idx)); - LastReportedStep = idx / 500; - } - - for (size_t len = 3; len < 700; len += 13) - { - Data.CopyBlockTypes(WritePosition, idx, len); - - // Verify the data copied: - for (size_t i = 0; i < len; i++) - { - TEST_EQUAL(WritePosition[i], 0x01); - } - // Verify the space before the copied data hasn't been changed: - for (size_t i = 0; i < WritePosIdx; i++) - { - TEST_EQUAL(TestBuffer[i], 0x03); - } - // Verify the space after the copied data hasn't been changed: - for (size_t i = WritePosIdx + idx + len; i < ARRAYCOUNT(TestBuffer); i++) - { - TEST_EQUAL(TestBuffer[i], 0x03); - } - - // Re-initialize the buffer for the next test: - for (size_t i = 0; i < len; i++) - { - WritePosition[i] = 0x03; - } - } // for len - } // for idx -} - - - - - -IMPLEMENT_TEST_MAIN("ChunkData CopyBlocks", - test() -) -- cgit v1.2.3