Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nhatdongdang committed Aug 12, 2024
1 parent addddc2 commit 05e7731
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions test/minecraft_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,32 @@ TEST_CASE("HeightMap functionality") {
CHECK_EQ(data.get_worldspace(Coordinate{-201, 0, -202}), 301);
}

SUBCASE("Iterator") {
mc.setBlocks(Coordinate{-200, 300, -200}, Coordinate{-210, 319, -210},
Blocks::AIR);
mc.setBlocks(Coordinate{-200, 300, -200}, Coordinate{-210, 300, -210},
Blocks::STONE);
mc.setBlock(Coordinate{-200, 301, -200}, Blocks::STONE);
mc.setBlock(Coordinate{-210, 301, -210}, Blocks::STONE);
mc.setBlock(Coordinate{-201, 301, -202}, Blocks::STONE);

HeightMap data =
mc.getHeights(Coordinate{-200, 0, -200}, Coordinate{-210, 0, -210});

std::vector<int> expected_heights;
for (int i = 0; i < data.x_len(); i++) {
for (int j = 0; j < data.z_len(); j++) {
expected_heights.push_back(data.get(i, j));
}
}

std::vector<int> heights;
for (int height : data) {
heights.push_back(height);
}
CHECK_EQ(heights, expected_heights);
}

// Clean up
mc.setBlocks(Coordinate{200, 300, 200}, Coordinate{210, 301, 210},
Blocks::AIR);
Expand Down

0 comments on commit 05e7731

Please sign in to comment.