minetest/src/unittest
JosiahWI 8e5bd82c4d
fix integer overflow in mapgen (#11641)
* fix integer overflow in mapgen

Some calculations involving the magic seed had overflow because the result of an intermediate arithmetic step could not fit in an s32. By making the magic seed unsigned, the other operand in the equation will be cast to unsigned, and possibly other operands or intermediate operands. This will result in unexpected behavior if an operand is negative, which is technically possible, but logically should not happen.

* comment noise2d bitshift

While working through the code I was momentarily concerned that the right bitshift in noise2d could fill ones in some cases. It turns out that with signed integers, this is indeed true, but this one is shifting an unsigned integer, so the behavior is as expected. I put a comment here to clarify this, in case someone else wonders the same thing down the line.

* noise2d and noise3d unittests

I have added 3 tests each for noise2d and noise3d, testing all zero inputs, a very large seed (case which caused UB in the old implementation) and some fun primes I picked for no particular reason. This should be sufficient to demonstrate that the behavior of the new implementation has not changed. I used uniform initialization because it is a good feature of C++11. Please do not explode.

* uncomment the noise2d bitshift

This reverts commit 583b77ee9f. It's a
well-defined language semantic; it doesn't need to be commented.

* code cleanliness
2022-06-03 20:51:58 -04:00
..
test_mod/test_mod Add "MINETEST_MOD_PATH" environment variable (#11515) 2021-10-07 00:19:41 +02:00
test_world Inventory: Send dirty lists where appropriate (#8742) 2019-08-24 19:07:38 +02:00
CMakeLists.txt Compile Lua as C++ (#11683) 2022-04-07 15:54:17 +01:00
test.cpp Replace all uses of core::list with std::list (#12313) 2022-05-22 00:11:59 +02:00
test.h Improve testSerializeJsonString unit tests 2022-05-21 17:46:10 +02:00
test_activeobject.cpp Add unittests on ActiveObject and BanManager class (#6866) 2018-01-01 18:48:52 +01:00
test_address.cpp Move the codebase to C++14 2022-02-26 14:39:41 +01:00
test_areastore.cpp Make sure relevant std::stringstreams are set to binary 2021-09-11 21:06:57 +02:00
test_authdatabase.cpp Fix temporary path crash in TestAuthDatabase (#7753) 2018-09-28 20:12:11 +02:00
test_ban.cpp TestBan: Clean up properly after completing test (#9994) 2020-06-05 20:04:14 +02:00
test_clientactiveobjectmgr.cpp fix: some code tidy about includes & irr namespaces 2021-05-03 19:49:19 +02:00
test_collision.cpp Collision various fixes (#9343) 2020-04-08 22:45:05 +02:00
test_compression.cpp Switch MapBlock compression to zstd (#10788) 2021-08-31 17:32:31 -07:00
test_config.h.in Add "MINETEST_MOD_PATH" environment variable (#11515) 2021-10-07 00:19:41 +02:00
test_connection.cpp Network: Delete copy constructor and use std::move instead (#11642) 2021-12-01 20:22:33 +01:00
test_eventmanager.cpp Move the codebase to C++14 2022-02-26 14:39:41 +01:00
test_filepath.cpp Fix RemoveRelatvePathComponents 2016-12-20 17:17:38 +10:00
test_gameui.cpp LINT fix 2018-05-29 22:22:14 +02:00
test_gettext.cpp Fix various code & correctness issues (#11815) 2021-12-05 14:40:30 +01:00
test_inventory.cpp Inventory: Send dirty lists where appropriate (#8742) 2019-08-24 19:07:38 +02:00
test_irrptr.cpp Fix compiler warnings 2022-04-08 14:55:21 +01:00
test_keycode.cpp Move client-specific files to 'src/client' (#7902) 2018-11-28 20:01:49 +01:00
test_lua.cpp Compile Lua as C++ (#11683) 2022-04-07 15:54:17 +01:00
test_map.cpp Raise max mapgen limit constant to align with mapblock size 2022-01-30 13:49:26 +01:00
test_map_settings_manager.cpp Rework Settings to support arbitrary hierarchies (#11352) 2021-06-23 15:22:31 +02:00
test_mapnode.cpp Node definition manager refactor (#7016) 2018-02-10 21:04:16 +01:00
test_modchannels.cpp Implement mod communication channels (#6351) 2017-09-26 00:11:20 +02:00
test_modmetadatadatabase.cpp Use a database for mod storage (#11763) 2022-01-07 20:28:49 +02:00
test_nodedef.cpp Modernize source code: last part (#6285) 2017-08-20 13:30:50 +02:00
test_noderesolver.cpp Schematic: Properly deal with before/after node resolving and document (#11011) 2021-03-20 13:02:15 +01:00
test_noise.cpp fix integer overflow in mapgen (#11641) 2022-06-03 20:51:58 -04:00
test_objdef.cpp Allow ObjDefManager instances to be cloned 2020-05-05 19:26:59 +02:00
test_profiler.cpp Pass clang-format on various cpp/header files (#5559) 2017-04-23 09:52:40 +02:00
test_random.cpp Fix many issues reported by clang-tidy (#7189) 2018-04-02 23:51:08 +02:00
test_schematic.cpp Schematic: Properly deal with before/after node resolving and document (#11011) 2021-03-20 13:02:15 +01:00
test_serialization.cpp Improve testSerializeJsonString unit tests 2022-05-21 17:46:10 +02:00
test_server_shutdown_state.cpp Move the codebase to C++14 2022-02-26 14:39:41 +01:00
test_serveractiveobjectmgr.cpp Optimize get_objects_inside_radius calls (#9671) 2020-04-16 08:25:48 +02:00
test_servermodmanager.cpp Add "MINETEST_MOD_PATH" environment variable (#11515) 2021-10-07 00:19:41 +02:00
test_settings.cpp Settings: Purge getDefault, clean FontEngine 2021-01-29 17:32:35 +01:00
test_socket.cpp Socket-related cleanups 2021-12-29 23:01:26 +01:00
test_threading.cpp Remove Thread::kill() and related unittest (#10317) 2020-09-10 12:19:18 +02:00
test_utilities.cpp Remove duplicate test for trim 2022-04-08 14:55:21 +01:00
test_voxelalgorithms.cpp Node definition manager refactor (#7016) 2018-02-10 21:04:16 +01:00
test_voxelarea.cpp Don't test overflow behavior for VoxelArea extents 2022-04-08 14:55:21 +01:00
test_voxelmanipulator.cpp Node definition manager refactor (#7016) 2018-02-10 21:04:16 +01:00