Skip to content

Commit

Permalink
Add test case for Chunk const iterator
Browse files Browse the repository at this point in the history
  • Loading branch information
dxrcy committed Dec 5, 2024
1 parent 1ca0568 commit 22c390e
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions test/minecraft_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ TEST_CASE("getBlocks and Chunk operations") {
mc.setBlock(loc2, Blocks::DIAMOND_BLOCK);
mc.setBlock(loc1 + Coordinate{1, 2, 3}, Blocks::IRON_BLOCK);
Chunk res = mc.getBlocks(loc1, loc2);
const Chunk res_const = mc.getBlocks(loc1, loc2);

SUBCASE("getters") {
Chunk data = mc.getBlocks(loc1, loc2);
Expand Down Expand Up @@ -201,6 +202,23 @@ TEST_CASE("getBlocks and Chunk operations") {
CHECK_EQ(blocks, expected_blocks);
}

SUBCASE("Const iterator") {
std::vector<BlockType> blocks;
for (int i = 0; i < res_const.y_len(); i++) {
for (int j = 0; j < res_const.x_len(); j++) {
for (int z = 0; z < res_const.z_len(); z++) {
blocks.push_back(res_const.get(j, i, z));
}
}
}

std::vector<BlockType> expected_blocks;
for (BlockType block : res_const) {
expected_blocks.push_back(block);
}
CHECK_EQ(blocks, expected_blocks);
}

mc.setBlock(test_loc, BlockType(0));
}

Expand Down

0 comments on commit 22c390e

Please sign in to comment.