aboutsummaryrefslogtreecommitdiff
path: root/src/unittest
ModeNameSize
-rw-r--r--CMakeLists.txt1083logplain
-rw-r--r--test.cpp17771logplain
-rw-r--r--test.h5903logplain
-rw-r--r--test_areastore.cpp3291logplain
-rw-r--r--test_collision.cpp5219logplain
-rw-r--r--test_compression.cpp4902logplain
-rw-r--r--test_connection.cpp8761logplain
-rw-r--r--test_filepath.cpp7835logplain
-rw-r--r--test_inventory.cpp3085logplain
-rw-r--r--test_mapnode.cpp1685logplain
-rw-r--r--test_nodedef.cpp1900logplain
-rw-r--r--test_noderesolver.cpp6652logplain
-rw-r--r--test_noise.cpp14699logplain
-rw-r--r--test_objdef.cpp2783logplain
-rw-r--r--test_profiler.cpp1844logplain
-rw-r--r--test_random.cpp10526logplain
-rw-r--r--test_schematic.cpp8331logplain
-rw-r--r--test_serialization.cpp20359logplain
-rw-r--r--test_settings.cpp5710logplain
-rw-r--r--test_socket.cpp3932logplain
-rw-r--r--test_threading.cpp4373logplain
-rw-r--r--test_utilities.cpp8402logplain
-rw-r--r--test_voxelalgorithms.cpp5957logplain
-rw-r--r--test_voxelmanipulator.cpp3157logplain
distribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include "test.h" #include "voxel.h" class TestVoxelArea : public TestBase { public: TestVoxelArea() { TestManager::registerTestModule(this); } const char *getName() { return "TestVoxelArea"; } void runTests(IGameDef *gamedef); void test_addarea(); void test_pad(); void test_volume(); void test_contains_voxelarea(); void test_contains_point(); void test_contains_i(); void test_equal(); void test_plus(); void test_minor(); void test_index_xyz_all_pos(); void test_index_xyz_x_neg(); void test_index_xyz_y_neg(); void test_index_xyz_z_neg(); void test_index_xyz_xy_neg(); void test_index_xyz_xz_neg(); void test_index_xyz_yz_neg(); void test_index_xyz_all_neg(); void test_index_v3s16_all_pos(); void test_index_v3s16_x_neg(); void test_index_v3s16_y_neg(); void test_index_v3s16_z_neg(); void test_index_v3s16_xy_neg(); void test_index_v3s16_xz_neg(); void test_index_v3s16_yz_neg(); void test_index_v3s16_all_neg(); void test_add_x(); void test_add_y(); void test_add_z(); void test_add_p(); }; static TestVoxelArea g_test_instance; void TestVoxelArea::runTests(IGameDef *gamedef) { TEST(test_addarea); TEST(test_pad); TEST(test_volume); TEST(test_contains_voxelarea); TEST(test_contains_point); TEST(test_contains_i); TEST(test_equal); TEST(test_plus); TEST(test_minor); TEST(test_index_xyz_all_pos); TEST(test_index_xyz_x_neg); TEST(test_index_xyz_y_neg); TEST(test_index_xyz_z_neg); TEST(test_index_xyz_xy_neg); TEST(test_index_xyz_xz_neg); TEST(test_index_xyz_yz_neg); TEST(test_index_xyz_all_neg); TEST(test_index_v3s16_all_pos); TEST(test_index_v3s16_x_neg); TEST(test_index_v3s16_y_neg); TEST(test_index_v3s16_z_neg); TEST(test_index_v3s16_xy_neg); TEST(test_index_v3s16_xz_neg); TEST(test_index_v3s16_yz_neg); TEST(test_index_v3s16_all_neg); TEST(test_add_x); TEST(test_add_y); TEST(test_add_z); TEST(test_add_p); } void TestVoxelArea::test_addarea() { VoxelArea v1(v3s16(-1447, 8854, -875), v3s16(-147, -9547, 669)); VoxelArea v2(v3s16(-887, 4445, -5478), v3s16(447, -8779, 4778)); v1.addArea(v2); UASSERT(v1.MinEdge == v3s16(-1447, 4445, -5478)); UASSERT(v1.MaxEdge == v3s16(447, -8779, 4778)); } void TestVoxelArea::test_pad() { VoxelArea v1(v3s16(-1447, 8854, -875), v3s16(-147, -9547, 669)); v1.pad(v3s16(100, 200, 300)); UASSERT(v1.MinEdge == v3s16(-1547, 8654, -1175)); UASSERT(v1.MaxEdge == v3s16(-47, -9347, 969)); } void TestVoxelArea::test_volume() { VoxelArea v1(v3s16(-1337, 447, -789), v3s16(-147, -9547, 669)); UASSERTEQ(s32, v1.getVolume(), -184657133); } void TestVoxelArea::test_contains_voxelarea() { VoxelArea v1(v3s16(-1337, -9547, -789), v3s16(-147, 750, 669)); UASSERTEQ(bool, v1.contains(VoxelArea(v3s16(-200, 10, 10), v3s16(-150, 10, 10))), true); UASSERTEQ(bool, v1.contains(VoxelArea(v3s16(-2550, 10, 10), v3s16(10, 10, 10))), false); UASSERTEQ(bool, v1.contains(VoxelArea(v3s16(-10, 10, 10), v3s16(3500, 10, 10))), false); UASSERTEQ(bool, v1.contains(VoxelArea( v3s16(-800, -400, 669), v3s16(-500, 200, 669))), true); UASSERTEQ(bool, v1.contains(VoxelArea( v3s16(-800, -400, 670), v3s16(-500, 200, 670))), false); } void TestVoxelArea::test_contains_point() { VoxelArea v1(v3s16(-1337, -9547, -789), v3s16(-147, 750, 669)); UASSERTEQ(bool, v1.contains(v3s16(-200, 10, 10)), true); UASSERTEQ(bool, v1.contains(v3s16(-10000, 10, 10)), false); UASSERTEQ(bool, v1.contains(v3s16(-100, 10000, 10)), false); UASSERTEQ(bool, v1.contains(v3s16(-100, 100, 10000)), false); UASSERTEQ(bool, v1.contains(v3s16(-100, 100, -10000)), false); UASSERTEQ(bool, v1.contains(v3s16(10000, 100, 10)), false); } void TestVoxelArea::test_contains_i() { VoxelArea v1(v3s16(-1337, -9547, -789), v3s16(-147, 750, 669)); UASSERTEQ(bool, v1.contains(10), true); UASSERTEQ(bool, v1.contains(v1.getVolume()), false); UASSERTEQ(bool, v1.contains(v1.getVolume() - 1), true); UASSERTEQ(bool, v1.contains(v1.getVolume() + 1), false); UASSERTEQ(bool, v1.contains(-1), false) VoxelArea v2(v3s16(10, 10, 10), v3s16(30, 30, 30)); UASSERTEQ(bool, v2.contains(10), true); UASSERTEQ(bool, v2.contains(0), true); UASSERTEQ(bool, v2.contains(-1), false); } void TestVoxelArea::test_equal() { VoxelArea v1(v3s16(-1337, -9547, -789), v3s16(-147, 750, 669));