From 73d70527323dcc848f39a9eba0b8964548761b6c Mon Sep 17 00:00:00 2001 From: Rubidium Date: Mon, 10 Apr 2023 19:02:31 +0200 Subject: [PATCH] Add: unit test functionality using catch2 (cherry picked from commit 43a7e54067b62a3fe783b37670c1a3329c14a7c5) --- .github/workflows/ci-build.yml | 2 +- .github/workflows/codeql.yml | 1 + CMakeLists.txt | 7 + cmake/SourceList.cmake | 23 + src/CMakeLists.txt | 1 + src/landscape.cpp | 92 ---- src/landscape_ppz.cpp | 89 ++++ src/tests/CMakeLists.txt | 8 +- src/tests/landscape_partial_pixel_z.cpp | 642 ++++++++++++++++++++++++ src/tests/landscape_partial_pixel_z.h | 552 -------------------- src/tests/math_func.cpp | 77 +++ src/tests/test_main.cpp | 29 ++ 12 files changed, 876 insertions(+), 647 deletions(-) create mode 100644 src/landscape_ppz.cpp create mode 100644 src/tests/landscape_partial_pixel_z.cpp delete mode 100644 src/tests/landscape_partial_pixel_z.h create mode 100644 src/tests/math_func.cpp create mode 100644 src/tests/test_main.cpp diff --git a/.github/workflows/ci-build.yml b/.github/workflows/ci-build.yml index 8e103ff7af..bf30fbcc9e 100644 --- a/.github/workflows/ci-build.yml +++ b/.github/workflows/ci-build.yml @@ -77,7 +77,7 @@ jobs: echo "::group::Build" echo "Running on $(nproc) cores" - cmake --build . -j $(nproc) + cmake --build . -j $(nproc) -t openttd echo "::endgroup::" linux: diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 47dcafc882..01a332fb10 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -88,6 +88,7 @@ jobs: +**/*.* -**/table/*.* -**/generated/**/*.* + -**/tests/*.* input: sarif-results/cpp.sarif output: sarif-results/cpp.sarif diff --git a/CMakeLists.txt b/CMakeLists.txt index 01104fb488..7a80c7d91d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -253,6 +253,7 @@ if(OPTION_PACKAGE_DEPENDENCIES) set(CMAKE_BUILD_WITH_INSTALL_RPATH ON) endif() +include(CTest) include(SourceList) # Needed by rev.cpp @@ -264,6 +265,9 @@ include(MSVCFilters) add_executable(openttd WIN32 ${GENERATED_SOURCE_FILES}) set_target_properties(openttd PROPERTIES OUTPUT_NAME "${BINARY_NAME}") + +add_executable(openttd_test) +set_target_properties(openttd_test PROPERTIES EXCLUDE_FROM_ALL TRUE) # All other files are added via target_sources() set(host_tools_list strgen settingsgen) @@ -327,6 +331,9 @@ target_link_libraries(openttd openttd::binfiles Threads::Threads ) +target_link_libraries(openttd_test) +include(Catch) +catch_discover_tests(openttd_test) if(HAIKU) target_link_libraries(openttd "be" "network" "midi") diff --git a/cmake/SourceList.cmake b/cmake/SourceList.cmake index 6e95be2017..e48fc61c1e 100644 --- a/cmake/SourceList.cmake +++ b/cmake/SourceList.cmake @@ -21,6 +21,29 @@ function(add_files) endforeach() endfunction() +# Add a test file to be compiled. +# +# add_test_files([file1 ...] CONDITION condition [condition ...]) +# +# CONDITION is a complete statement that can be evaluated with if(). +# If it evaluates true, the source files will be added; otherwise not. +# For example: ADD_IF SDL_FOUND AND Allegro_FOUND +# +function(add_test_files) + cmake_parse_arguments(PARAM "" "" "CONDITION" ${ARGN}) + set(PARAM_FILES "${PARAM_UNPARSED_ARGUMENTS}") + + if(PARAM_CONDITION) + if(NOT (${PARAM_CONDITION})) + return() + endif() + endif() + + foreach(FILE IN LISTS PARAM_FILES) + target_sources(openttd_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/${FILE}) + endforeach() +endfunction() + # This function works around an 'issue' with CMake, where # set_source_files_properties() only works in the scope of the file. We want # to set properties for the source file on a more global level. To solve this, diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 73df4622a3..5fc7611119 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -230,6 +230,7 @@ add_files( infrastructure_func.h intro_gui.cpp landscape.cpp + landscape_ppz.cpp landscape.h landscape_type.h language.h diff --git a/src/landscape.cpp b/src/landscape.cpp index dfc4d88387..2aac3fe701 100644 --- a/src/landscape.cpp +++ b/src/landscape.cpp @@ -226,98 +226,6 @@ uint ApplyFoundationToSlope(Foundation f, Slope *s) return dz; } - -/** - * Determines height at given coordinate of a slope. - * - * At the northern corner (0, 0) the result is always a multiple of TILE_HEIGHT. - * When the height is a fractional Z, then the height is rounded down. For example, - * when at the height is 0 at x = 0 and the height is 8 at x = 16 (actually x = 0 - * of the next tile), then height is 0 at x = 1, 1 at x = 2, and 7 at x = 15. - * @param x x coordinate (value from 0 to 15) - * @param y y coordinate (value from 0 to 15) - * @param corners slope to examine - * @return height of given point of given slope - */ -static constexpr uint InternalGetPartialPixelZ(int x, int y, Slope corners) -{ - if (IsHalftileSlope(corners)) { - /* A foundation is placed on half the tile at a specific corner. This means that, - * depending on the corner, that one half of the tile is at the maximum height. */ - switch (GetHalftileSlopeCorner(corners)) { - case CORNER_W: - if (x > y) return GetSlopeMaxPixelZ(corners); - break; - - case CORNER_S: - if (x + y >= (int)TILE_SIZE) return GetSlopeMaxPixelZ(corners); - break; - - case CORNER_E: - if (x <= y) return GetSlopeMaxPixelZ(corners); - break; - - case CORNER_N: - if (x + y < (int)TILE_SIZE) return GetSlopeMaxPixelZ(corners); - break; - - default: NOT_REACHED(); - } - } - - switch (RemoveHalftileSlope(corners)) { - case SLOPE_FLAT: return 0; - - /* One corner is up.*/ - case SLOPE_N: return x + y <= (int)TILE_SIZE ? (TILE_SIZE - x - y) >> 1 : 0; - case SLOPE_E: return y >= x ? (1 + y - x) >> 1 : 0; - case SLOPE_S: return x + y >= (int)TILE_SIZE ? (1 + x + y - TILE_SIZE) >> 1 : 0; - case SLOPE_W: return x >= y ? (x - y) >> 1 : 0; - - /* Two corners next to eachother are up. */ - case SLOPE_NE: return (TILE_SIZE - x) >> 1; - case SLOPE_SE: return (y + 1) >> 1; - case SLOPE_SW: return (x + 1) >> 1; - case SLOPE_NW: return (TILE_SIZE - y) >> 1; - - /* Three corners are up on the same level. */ - case SLOPE_ENW: return x + y >= (int)TILE_SIZE ? TILE_HEIGHT - ((1 + x + y - TILE_SIZE) >> 1) : TILE_HEIGHT; - case SLOPE_SEN: return y < x ? TILE_HEIGHT - ((x - y) >> 1) : TILE_HEIGHT; - case SLOPE_WSE: return x + y <= (int)TILE_SIZE ? TILE_HEIGHT - ((TILE_SIZE - x - y) >> 1) : TILE_HEIGHT; - case SLOPE_NWS: return x < y ? TILE_HEIGHT - ((1 + y - x) >> 1) : TILE_HEIGHT; - - /* Two corners at opposite sides are up. */ - case SLOPE_NS: return x + y < (int)TILE_SIZE ? (TILE_SIZE - x - y) >> 1 : (1 + x + y - TILE_SIZE) >> 1; - case SLOPE_EW: return x >= y ? (x - y) >> 1 : (1 + y - x) >> 1; - - /* Very special cases. */ - case SLOPE_ELEVATED: return TILE_HEIGHT; - - /* Steep slopes. The top is at 2 * TILE_HEIGHT. */ - case SLOPE_STEEP_N: return (TILE_SIZE - x + TILE_SIZE - y) >> 1; - case SLOPE_STEEP_E: return (TILE_SIZE + 1 + y - x) >> 1; - case SLOPE_STEEP_S: return (1 + x + y) >> 1; - case SLOPE_STEEP_W: return (TILE_SIZE + x - y) >> 1; - - default: NOT_REACHED(); - } -} - -#include "tests/landscape_partial_pixel_z.h" - -/** - * Determines height at given coordinate of a slope. - * See #InternalGetPartialPixelZ. - * @param x x coordinate (value from 0 to 15) - * @param y y coordinate (value from 0 to 15) - * @param corners slope to examine - * @return height of given point of given slope - */ -uint GetPartialPixelZ(int x, int y, Slope corners) -{ - return InternalGetPartialPixelZ(x, y, corners); -} - /** * Return world \c Z coordinate of a given point of a tile. Normally this is the * Z of the ground/foundation at the given location, but in some cases the diff --git a/src/landscape_ppz.cpp b/src/landscape_ppz.cpp new file mode 100644 index 0000000000..c9eefd68e5 --- /dev/null +++ b/src/landscape_ppz.cpp @@ -0,0 +1,89 @@ +/* + * This file is part of OpenTTD. + * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. + * OpenTTD 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 General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see . + */ + +/** @file landscape_ppz.cpp Functions related to landscape partial pixel z. */ + +#include "stdafx.h" +#include "slope_func.h" + +#include "safeguards.h" + +/** + * Determines height at given coordinate of a slope. + * + * At the northern corner (0, 0) the result is always a multiple of TILE_HEIGHT. + * When the height is a fractional Z, then the height is rounded down. For example, + * when at the height is 0 at x = 0 and the height is 8 at x = 16 (actually x = 0 + * of the next tile), then height is 0 at x = 1, 1 at x = 2, and 7 at x = 15. + * @param x x coordinate (value from 0 to 15) + * @param y y coordinate (value from 0 to 15) + * @param corners slope to examine + * @return height of given point of given slope + */ +uint GetPartialPixelZ(int x, int y, Slope corners) +{ + if (IsHalftileSlope(corners)) { + /* A foundation is placed on half the tile at a specific corner. This means that, + * depending on the corner, that one half of the tile is at the maximum height. */ + switch (GetHalftileSlopeCorner(corners)) { + case CORNER_W: + if (x > y) return GetSlopeMaxPixelZ(corners); + break; + + case CORNER_S: + if (x + y >= (int)TILE_SIZE) return GetSlopeMaxPixelZ(corners); + break; + + case CORNER_E: + if (x <= y) return GetSlopeMaxPixelZ(corners); + break; + + case CORNER_N: + if (x + y < (int)TILE_SIZE) return GetSlopeMaxPixelZ(corners); + break; + + default: NOT_REACHED(); + } + } + + switch (RemoveHalftileSlope(corners)) { + case SLOPE_FLAT: return 0; + + /* One corner is up.*/ + case SLOPE_N: return x + y <= (int)TILE_SIZE ? (TILE_SIZE - x - y) >> 1 : 0; + case SLOPE_E: return y >= x ? (1 + y - x) >> 1 : 0; + case SLOPE_S: return x + y >= (int)TILE_SIZE ? (1 + x + y - TILE_SIZE) >> 1 : 0; + case SLOPE_W: return x >= y ? (x - y) >> 1 : 0; + + /* Two corners next to eachother are up. */ + case SLOPE_NE: return (TILE_SIZE - x) >> 1; + case SLOPE_SE: return (y + 1) >> 1; + case SLOPE_SW: return (x + 1) >> 1; + case SLOPE_NW: return (TILE_SIZE - y) >> 1; + + /* Three corners are up on the same level. */ + case SLOPE_ENW: return x + y >= (int)TILE_SIZE ? TILE_HEIGHT - ((1 + x + y - TILE_SIZE) >> 1) : TILE_HEIGHT; + case SLOPE_SEN: return y < x ? TILE_HEIGHT - ((x - y) >> 1) : TILE_HEIGHT; + case SLOPE_WSE: return x + y <= (int)TILE_SIZE ? TILE_HEIGHT - ((TILE_SIZE - x - y) >> 1) : TILE_HEIGHT; + case SLOPE_NWS: return x < y ? TILE_HEIGHT - ((1 + y - x) >> 1) : TILE_HEIGHT; + + /* Two corners at opposite sides are up. */ + case SLOPE_NS: return x + y < (int)TILE_SIZE ? (TILE_SIZE - x - y) >> 1 : (1 + x + y - TILE_SIZE) >> 1; + case SLOPE_EW: return x >= y ? (x - y) >> 1 : (1 + y - x) >> 1; + + /* Very special cases. */ + case SLOPE_ELEVATED: return TILE_HEIGHT; + + /* Steep slopes. The top is at 2 * TILE_HEIGHT. */ + case SLOPE_STEEP_N: return (TILE_SIZE - x + TILE_SIZE - y) >> 1; + case SLOPE_STEEP_E: return (TILE_SIZE + 1 + y - x) >> 1; + case SLOPE_STEEP_S: return (1 + x + y) >> 1; + case SLOPE_STEEP_W: return (TILE_SIZE + x - y) >> 1; + + default: NOT_REACHED(); + } +} diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index d028125ae9..2255f24112 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -1,3 +1,7 @@ -add_files( - landscape_partial_pixel_z.h +add_test_files( + landscape_partial_pixel_z.cpp + math_func.cpp + test_main.cpp + ../landscape_ppz.cpp + ../core/math_func.cpp ) diff --git a/src/tests/landscape_partial_pixel_z.cpp b/src/tests/landscape_partial_pixel_z.cpp new file mode 100644 index 0000000000..f5c22786f7 --- /dev/null +++ b/src/tests/landscape_partial_pixel_z.cpp @@ -0,0 +1,642 @@ +/* + * This file is part of OpenTTD. + * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. + * OpenTTD 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 General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see . + */ + +/** @file landscape_partial_pixel_z.cpp Tests for consistency/validity of the results of GetPartialPixelZ. */ + +#include "../stdafx.h" + +#include "../3rdparty/catch2/catch.hpp" + +#include "../landscape.h" +#include "../slope_func.h" +#include + +/** + * Check whether the addition of two slope's GetPartialPixelZ values results in + * the GetPartialPixelZ values of the expected slope. + * This iterates over all sub-pixel locations within a single tile. + * @param slope_expected The slope that is expected. + * @param slope_a The first slope of the addition. + * @param slope_b The second slope of the addition. + * @return True iff at all GetPartialPixelZ results are the same for each sub-tile position. + */ +bool CheckPartialPixelZSlopeAddition(Slope slope_expected, Slope slope_a, Slope slope_b) +{ + for (uint x = 0; x < TILE_SIZE; x++) { + for (uint y = 0; y < TILE_SIZE; y++) { + int z_a = GetPartialPixelZ(x, y, slope_a); + int z_b = GetPartialPixelZ(x, y, slope_b); + int z_result = GetPartialPixelZ(x, y, slope_expected); + if (z_result != z_a + z_b) return false; + } + } + return true; +} + +TEST_CASE("PartialPixelSlopeAdditionTest - A one corner slope, plus the opposite three corner slope results in a flat but elevated slope") +{ + CHECK(CheckPartialPixelZSlopeAddition(SLOPE_ELEVATED, SLOPE_N, SLOPE_WSE)); + CHECK(CheckPartialPixelZSlopeAddition(SLOPE_ELEVATED, SLOPE_E, SLOPE_NWS)); + CHECK(CheckPartialPixelZSlopeAddition(SLOPE_ELEVATED, SLOPE_S, SLOPE_ENW)); + CHECK(CheckPartialPixelZSlopeAddition(SLOPE_ELEVATED, SLOPE_W, SLOPE_SEN)); +} + +TEST_CASE("PartialPixelSlopeAdditionTest - Diagonal slopes with their opposite slope result in a flat but elevated slope") +{ + CHECK(CheckPartialPixelZSlopeAddition(SLOPE_ELEVATED, SLOPE_NW, SLOPE_SE)); + CHECK(CheckPartialPixelZSlopeAddition(SLOPE_ELEVATED, SLOPE_SW, SLOPE_NE)); +} + +TEST_CASE("PartialPixelSlopeAdditionTest - Half tile slopes with their opposite half tile slope result in a flat but elevated slope") +{ + CHECK(CheckPartialPixelZSlopeAddition(SLOPE_ELEVATED, HalftileSlope(SLOPE_N, CORNER_N), HalftileSlope(SLOPE_S, CORNER_S))); + CHECK(CheckPartialPixelZSlopeAddition(SLOPE_ELEVATED, HalftileSlope(SLOPE_E, CORNER_E), HalftileSlope(SLOPE_W, CORNER_W))); +} + +TEST_CASE("PartialPixelSlopeAdditionTest - Two opposite one corner slopes result in the two corner slope with opposite corners") +{ + CHECK(CheckPartialPixelZSlopeAddition(SLOPE_NS, SLOPE_N, SLOPE_S)); + CHECK(CheckPartialPixelZSlopeAddition(SLOPE_EW, SLOPE_E, SLOPE_W)); +} + +TEST_CASE("PartialPixelSlopeAdditionTest - A steep slope is a one corner slope on top of a three corner slope") +{ + CHECK(CheckPartialPixelZSlopeAddition(SLOPE_STEEP_N, SLOPE_N, SLOPE_ENW)); + CHECK(CheckPartialPixelZSlopeAddition(SLOPE_STEEP_E, SLOPE_E, SLOPE_SEN)); + CHECK(CheckPartialPixelZSlopeAddition(SLOPE_STEEP_S, SLOPE_S, SLOPE_WSE)); + CHECK(CheckPartialPixelZSlopeAddition(SLOPE_STEEP_W, SLOPE_W, SLOPE_NWS)); +} + +TEST_CASE("PartialPixelSlopeAdditionTest - A half tile steep slope is a one corner half tile on top of a three corner slope") +{ + CHECK(CheckPartialPixelZSlopeAddition(HalftileSlope(SLOPE_STEEP_N, CORNER_N), HalftileSlope(SLOPE_N, CORNER_N), SLOPE_ENW)); + CHECK(CheckPartialPixelZSlopeAddition(HalftileSlope(SLOPE_STEEP_E, CORNER_E), HalftileSlope(SLOPE_E, CORNER_E), SLOPE_SEN)); + CHECK(CheckPartialPixelZSlopeAddition(HalftileSlope(SLOPE_STEEP_S, CORNER_S), HalftileSlope(SLOPE_S, CORNER_S), SLOPE_WSE)); + CHECK(CheckPartialPixelZSlopeAddition(HalftileSlope(SLOPE_STEEP_W, CORNER_W), HalftileSlope(SLOPE_W, CORNER_W), SLOPE_NWS)); +} + +/** + * Check whether the partial pixel Z values are the expected values. The arrays + * are as if the map is rotated 45 degrees counterclockwise. + * @param slope The slope that is to be checked. + * @param expected The expect partial pixels Z values. + * @return True iff at all GetPartialPixelZ results are the same as the expected Z-coordinates. + */ +bool CheckPartialPixelZ(Slope slope, std::array expected) +{ + for (uint i = 0; i < expected.size(); i++) { + int actual = GetPartialPixelZ(GB(i, 4, 4), GB(i, 0, 4), slope); + if (actual != expected[i]) return false; + } + return true; +} + +TEST_CASE("PartialPixelTest - One corner up slopes - SLOPE_N") +{ + CHECK(CheckPartialPixelZ(SLOPE_N, { + 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 0, + 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 0, 0, + 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 0, 0, 0, + 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 0, 0, 0, 0, + 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 0, 0, 0, 0, 0, + 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 0, 0, 0, 0, 0, 0, + 5, 4, 4, 3, 3, 2, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, + 4, 4, 3, 3, 2, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, + 4, 3, 3, 2, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 3, 3, 2, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 3, 2, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 2, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0})); +} + +TEST_CASE("PartialPixelTest - One corner up slopes - SLOPE_S") +{ + CHECK(CheckPartialPixelZ(SLOPE_S, { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 2, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 2, 3, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, + 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, + 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, + 0, 0, 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, + 0, 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, + 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, + 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, + 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7})); +} + +TEST_CASE("PartialPixelTest - One corner up slopes - SLOPE_W") +{ + CHECK(CheckPartialPixelZ(SLOPE_W, { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0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 2, 1, 1, 0, + 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 0})); +} + +TEST_CASE("PartialPixelTest - Two opposite corner up slopes - SLOPE_NS") +{ + CHECK(CheckPartialPixelZ(SLOPE_NS, { + 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 0, + 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 0, 0, + 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 0, 0, 1, + 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 0, 0, 1, 1, + 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 0, 0, 1, 1, 2, + 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 0, 0, 1, 1, 2, 2, + 5, 4, 4, 3, 3, 2, 2, 1, 1, 0, 0, 1, 1, 2, 2, 3, + 4, 4, 3, 3, 2, 2, 1, 1, 0, 0, 1, 1, 2, 2, 3, 3, + 4, 3, 3, 2, 2, 1, 1, 0, 0, 1, 1, 2, 2, 3, 3, 4, + 3, 3, 2, 2, 1, 1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, + 3, 2, 2, 1, 1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, + 2, 2, 1, 1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, + 2, 1, 1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, + 1, 1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, + 1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, + 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7})); +} + +TEST_CASE("PartialPixelTest - Two opposite corner up slopes - SLOPE_EW") +{ + CHECK(CheckPartialPixelZ(SLOPE_EW, { + 0, 1, 1, 2, 2, 3, 3, 4, 4, 5,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 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 7, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8})); +} + +TEST_CASE("PartialPixelTest - Normal half tile slopes - SLOPE/CORNER_N") +{ + CHECK(CheckPartialPixelZ(HalftileSlope(SLOPE_N, CORNER_N), { + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 0, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 0, 0, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 0, 0, 0, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 0, 0, 0, 0, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 0, 0, 0, 0, 0, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 0, 0, 0, 0, 0, 0, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 0, 0, 0, 0, 0, 0, 0, + 8, 8, 8, 8, 8, 8, 8, 8, 0, 0, 0, 0, 0, 0, 0, 0, + 8, 8, 8, 8, 8, 8, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 8, 8, 8, 8, 8, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 8, 8, 8, 8, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 8, 8, 8, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 8, 8, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 8, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0})); +} + +TEST_CASE("PartialPixelTest - Normal half tile slopes - SLOPE/CORNER_E") +{ + CHECK(CheckPartialPixelZ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, 0, 0, 0, 0, 0, 0, + 8, 8, 8, 8, 8, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 8, 8, 8, 8, 8, 8, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 8, 8, 8, 8, 8, 8, 8, 8, 0, 0, 0, 0, 0, 0, 0, 0, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 0, 0, 0, 0, 0, 0, 0, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 0, 0, 0, 0, 0, 0, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 0, 0, 0, 0, 0, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 0, 0, 0, 0, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 0, 0, 0, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 0, 0, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 0})); +} + +TEST_CASE("PartialPixelTest - Steep slopes - SLOPE_STEEP_N") +{ + CHECK(CheckPartialPixelZ(SLOPE_STEEP_N, { + 16, 15, 15, 14, 14, 13, 13, 12, 12, 11, 11, 10, 10, 9, 9, 8, + 15, 15, 14, 14, 13, 13, 12, 12, 11, 11, 10, 10, 9, 9, 8, 8, + 15, 14, 14, 13, 13, 12, 12, 11, 11, 10, 10, 9, 9, 8, 8, 7, + 14, 14, 13, 13, 12, 12, 11, 11, 10, 10, 9, 9, 8, 8, 7, 7, + 14, 13, 13, 12, 12, 11, 11, 10, 10, 9, 9, 8, 8, 7, 7, 6, + 13, 13, 12, 12, 11, 11, 10, 10, 9, 9, 8, 8, 7, 7, 6, 6, + 13, 12, 12, 11, 11, 10, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, + 12, 12, 11, 11, 10, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, + 12, 11, 11, 10, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, + 11, 11, 10, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, + 11, 10, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, + 10, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, + 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, + 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, + 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, + 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1})); +} + +TEST_CASE("PartialPixelTest - Steep slopes - SLOPE_STEEP_E") +{ + CHECK(CheckPartialPixelZ(SLOPE_STEEP_E, { + 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, + 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, + 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, + 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, + 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, + 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, + 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, + 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, + 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, + 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, + 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, + 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, + 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, + 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, + 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, + 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8})); +} + +TEST_CASE("PartialPixelTest - Steep slopes - SLOPE_STEEP_S") +{ + CHECK(CheckPartialPixelZ(SLOPE_STEEP_S, { + 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, + 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, + 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, + 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, + 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, + 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, + 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, + 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, + 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, + 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, + 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, + 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, + 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, + 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, + 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, + 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15})); +} + +TEST_CASE("PartialPixelTest - Steep slopes - SLOPE_STEEP_W") +{ + CHECK(CheckPartialPixelZ(SLOPE_STEEP_W, { + 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 0, + 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, + 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, + 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, + 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, + 10, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, + 11, 10, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, + 11, 11, 10, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, + 12, 11, 11, 10, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, + 12, 12, 11, 11, 10, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, + 13, 12, 12, 11, 11, 10, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, + 13, 13, 12, 12, 11, 11, 10, 10, 9, 9, 8, 8, 7, 7, 6, 6, + 14, 13, 13, 12, 12, 11, 11, 10, 10, 9, 9, 8, 8, 7, 7, 6, + 14, 14, 13, 13, 12, 12, 11, 11, 10, 10, 9, 9, 8, 8, 7, 7, + 15, 14, 14, 13, 13, 12, 12, 11, 11, 10, 10, 9, 9, 8, 8, 7, + 15, 15, 14, 14, 13, 13, 12, 12, 11, 11, 10, 10, 9, 9, 8, 8})); +} + +TEST_CASE("PartialPixelTest - Half tile on top of steep slopes - SLOPE_STEEP/CORNER_N") +{ + CHECK(CheckPartialPixelZ(HalftileSlope(SLOPE_STEEP_N, CORNER_N), { + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 8, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 8, 7, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 8, 7, 7, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 8, 7, 7, 6, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 8, 7, 7, 6, 6, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 8, 7, 7, 6, 6, 5, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 8, 7, 7, 6, 6, 5, 5, + 16, 16, 16, 16, 16, 16, 16, 16, 8, 7, 7, 6, 6, 5, 5, 4, + 16, 16, 16, 16, 16, 16, 16, 8, 7, 7, 6, 6, 5, 5, 4, 4, + 16, 16, 16, 16, 16, 16, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, + 16, 16, 16, 16, 16, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, + 16, 16, 16, 16, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, + 16, 16, 16, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, + 16, 16, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, + 16, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1})); +} + +TEST_CASE("PartialPixelTest - Half tile on top of steep slopes - SLOPE_STEEP/CORNER_E") +{ + CHECK(CheckPartialPixelZ(HalftileSlope(SLOPE_STEEP_E, CORNER_E), { + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 8, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 7, 8, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 7, 7, 8, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 6, 7, 7, 8, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 6, 6, 7, 7, 8, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 5, 6, 6, 7, 7, 8, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 5, 5, 6, 6, 7, 7, 8, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 4, 5, 5, 6, 6, 7, 7, 8, 16, 16, 16, 16, 16, 16, 16, 16, + 4, 4, 5, 5, 6, 6, 7, 7, 8, 16, 16, 16, 16, 16, 16, 16, + 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 16, 16, 16, 16, 16, 16, + 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 16, 16, 16, 16, 16, + 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 16, 16, 16, 16, + 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 16, 16, 16, + 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 16, 16, + 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 16})); +} + +TEST_CASE("PartialPixelTest - Half tile on top of steep slopes - SLOPE_STEEP/CORNER_S") +{ + CHECK(CheckPartialPixelZ(HalftileSlope(SLOPE_STEEP_S, CORNER_S), { + 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, + 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 16, + 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 16, 16, + 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 16, 16, 16, + 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 16, 16, 16, 16, + 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 16, 16, 16, 16, 16, + 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 16, 16, 16, 16, 16, 16, + 4, 4, 5, 5, 6, 6, 7, 7, 8, 16, 16, 16, 16, 16, 16, 16, + 4, 5, 5, 6, 6, 7, 7, 8, 16, 16, 16, 16, 16, 16, 16, 16, + 5, 5, 6, 6, 7, 7, 8, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 5, 6, 6, 7, 7, 8, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 6, 6, 7, 7, 8, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 6, 7, 7, 8, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 7, 7, 8, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 7, 8, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 8, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16})); +} + +TEST_CASE("PartialPixelTest - Half tile on top of steep slopes - SLOPE_STEEP/CORNER_W") +{ + CHECK(CheckPartialPixelZ(HalftileSlope(SLOPE_STEEP_W, CORNER_W), { + 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 0, + 16, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, + 16, 16, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, + 16, 16, 16, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, + 16, 16, 16, 16, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, + 16, 16, 16, 16, 16, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, + 16, 16, 16, 16, 16, 16, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, + 16, 16, 16, 16, 16, 16, 16, 8, 7, 7, 6, 6, 5, 5, 4, 4, + 16, 16, 16, 16, 16, 16, 16, 16, 8, 7, 7, 6, 6, 5, 5, 4, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 8, 7, 7, 6, 6, 5, 5, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 8, 7, 7, 6, 6, 5, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 8, 7, 7, 6, 6, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 8, 7, 7, 6, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 8, 7, 7, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 8, 7, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 8})); +} diff --git a/src/tests/landscape_partial_pixel_z.h b/src/tests/landscape_partial_pixel_z.h deleted file mode 100644 index a825709392..0000000000 --- a/src/tests/landscape_partial_pixel_z.h +++ /dev/null @@ -1,552 +0,0 @@ -/* - * This file is part of OpenTTD. - * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. - * OpenTTD 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 General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see . - */ - -/** @file landscape_partial_pixel_z.h Tests for consistency/validity of the results of GetPartialPixelZ. */ - -/** - * Check whether the addition of two slope's GetPartialPixelZ values results in - * the GetPartialPixelZ values of the expected slope. - * This iterates over all sub-pixel locations within a single tile. - * @param slope_expected The slope that is expected. - * @param slope_a The first slope of the addition. - * @param slope_b The second slope of the addition. - * @return True iff at all GetPartialPixelZ results are the same for each sub-tile position. - */ -constexpr bool CheckPartialPixelZSlopeAddition(Slope slope_expected, Slope slope_a, Slope slope_b) -{ - for (uint x = 0; x < TILE_SIZE; x++) { - for (uint y = 0; y < TILE_SIZE; y++) { - int z_a = InternalGetPartialPixelZ(x, y, slope_a); - int z_b = InternalGetPartialPixelZ(x, y, slope_b); - int z_result = InternalGetPartialPixelZ(x, y, slope_expected); - if (z_result != z_a + z_b) return false; - } - } - return true; -} - -/* A one corner slope, plus the opposite three corner slope results in a flat but elevated slope. */ -static_assert(CheckPartialPixelZSlopeAddition(SLOPE_ELEVATED, SLOPE_N, SLOPE_WSE)); -static_assert(CheckPartialPixelZSlopeAddition(SLOPE_ELEVATED, SLOPE_E, SLOPE_NWS)); -static_assert(CheckPartialPixelZSlopeAddition(SLOPE_ELEVATED, SLOPE_S, SLOPE_ENW)); -static_assert(CheckPartialPixelZSlopeAddition(SLOPE_ELEVATED, SLOPE_W, SLOPE_SEN)); - -/* Diagonal slopes with their opposite slope result in a flat but elevated slope. */ -static_assert(CheckPartialPixelZSlopeAddition(SLOPE_ELEVATED, SLOPE_NW, SLOPE_SE)); -static_assert(CheckPartialPixelZSlopeAddition(SLOPE_ELEVATED, SLOPE_SW, SLOPE_NE)); - -/* Half tile slopes with their opposite half tile slope result in a flat but elevated slope. */ -static_assert(CheckPartialPixelZSlopeAddition(SLOPE_ELEVATED, HalftileSlope(SLOPE_N, CORNER_N), HalftileSlope(SLOPE_S, CORNER_S))); -static_assert(CheckPartialPixelZSlopeAddition(SLOPE_ELEVATED, HalftileSlope(SLOPE_E, CORNER_E), HalftileSlope(SLOPE_W, CORNER_W))); - -/* Two opposite one corner slopes result in the two corner slope with opposite corners. */ -static_assert(CheckPartialPixelZSlopeAddition(SLOPE_NS, SLOPE_N, SLOPE_S)); -static_assert(CheckPartialPixelZSlopeAddition(SLOPE_EW, SLOPE_E, SLOPE_W)); - -/* A steep slope is a one corner slope on top of a three corner slope. */ -static_assert(CheckPartialPixelZSlopeAddition(SLOPE_STEEP_N, SLOPE_N, SLOPE_ENW)); -static_assert(CheckPartialPixelZSlopeAddition(SLOPE_STEEP_E, SLOPE_E, SLOPE_SEN)); -static_assert(CheckPartialPixelZSlopeAddition(SLOPE_STEEP_S, SLOPE_S, SLOPE_WSE)); -static_assert(CheckPartialPixelZSlopeAddition(SLOPE_STEEP_W, SLOPE_W, SLOPE_NWS)); - -/* A half tile steep slope is a one corner half tile on top of a three corner slope. */ -static_assert(CheckPartialPixelZSlopeAddition(HalftileSlope(SLOPE_STEEP_N, CORNER_N), HalftileSlope(SLOPE_N, CORNER_N), SLOPE_ENW)); -static_assert(CheckPartialPixelZSlopeAddition(HalftileSlope(SLOPE_STEEP_E, CORNER_E), HalftileSlope(SLOPE_E, CORNER_E), SLOPE_SEN)); -static_assert(CheckPartialPixelZSlopeAddition(HalftileSlope(SLOPE_STEEP_S, CORNER_S), HalftileSlope(SLOPE_S, CORNER_S), SLOPE_WSE)); -static_assert(CheckPartialPixelZSlopeAddition(HalftileSlope(SLOPE_STEEP_W, CORNER_W), HalftileSlope(SLOPE_W, CORNER_W), SLOPE_NWS)); - - -/** - * Check whether the partial pixel Z values are the expected values. The arrays - * are as if the map is rotated 45 degrees counterclockwise. - * @param slope The slope that is to be checked. - * @param expected The expect partial pixels Z values. - * @return True iff at all GetPartialPixelZ results are the same as the expected Z-coordinates. - */ -constexpr bool CheckPartialPixelZ(Slope slope, std::array expected) -{ - for (uint i = 0; i < expected.size(); i++) { - int actual = InternalGetPartialPixelZ(GB(i, 4, 4), GB(i, 0, 4), slope); - if (actual != expected[i]) return false; - } - return true; -} - -/* One corner up slopes. */ -static_assert(CheckPartialPixelZ(SLOPE_N, { - 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 0, - 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 0, 0, - 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 0, 0, 0, - 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 0, 0, 0, 0, - 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 0, 0, 0, 0, 0, - 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 0, 0, 0, 0, 0, 0, - 5, 4, 4, 3, 3, 2, 2, 1, 1, 0, 0, 0, 0, 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 8, 8, 8, 8, 8, 8, 0, 0, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 0})); - -/* Steep slopes. */ -static_assert(CheckPartialPixelZ(SLOPE_STEEP_N, { - 16, 15, 15, 14, 14, 13, 13, 12, 12, 11, 11, 10, 10, 9, 9, 8, - 15, 15, 14, 14, 13, 13, 12, 12, 11, 11, 10, 10, 9, 9, 8, 8, - 15, 14, 14, 13, 13, 12, 12, 11, 11, 10, 10, 9, 9, 8, 8, 7, - 14, 14, 13, 13, 12, 12, 11, 11, 10, 10, 9, 9, 8, 8, 7, 7, - 14, 13, 13, 12, 12, 11, 11, 10, 10, 9, 9, 8, 8, 7, 7, 6, - 13, 13, 12, 12, 11, 11, 10, 10, 9, 9, 8, 8, 7, 7, 6, 6, - 13, 12, 12, 11, 11, 10, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, - 12, 12, 11, 11, 10, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, - 12, 11, 11, 10, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, - 11, 11, 10, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, - 11, 10, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, - 10, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, - 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, - 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, - 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, - 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1})); - -static_assert(CheckPartialPixelZ(SLOPE_STEEP_E, { - 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, - 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, - 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, - 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, - 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, - 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, - 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, - 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, - 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, - 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, - 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, - 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, - 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, - 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, - 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, - 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8})); - -static_assert(CheckPartialPixelZ(SLOPE_STEEP_S, { - 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, - 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, - 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, - 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, - 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, - 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, - 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, - 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, - 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, - 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, - 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, - 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, - 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, - 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, - 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, - 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15})); - -static_assert(CheckPartialPixelZ(SLOPE_STEEP_W, { - 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 0, - 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, - 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, - 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, - 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, - 10, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, - 11, 10, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, - 11, 11, 10, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, - 12, 11, 11, 10, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, - 12, 12, 11, 11, 10, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, - 13, 12, 12, 11, 11, 10, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, - 13, 13, 12, 12, 11, 11, 10, 10, 9, 9, 8, 8, 7, 7, 6, 6, - 14, 13, 13, 12, 12, 11, 11, 10, 10, 9, 9, 8, 8, 7, 7, 6, - 14, 14, 13, 13, 12, 12, 11, 11, 10, 10, 9, 9, 8, 8, 7, 7, - 15, 14, 14, 13, 13, 12, 12, 11, 11, 10, 10, 9, 9, 8, 8, 7, - 15, 15, 14, 14, 13, 13, 12, 12, 11, 11, 10, 10, 9, 9, 8, 8})); - -/* Half tile on top of steep slopes. */ -static_assert(CheckPartialPixelZ(HalftileSlope(SLOPE_STEEP_N, CORNER_N), { - 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, - 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 8, - 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 8, 7, - 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 8, 7, 7, - 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 8, 7, 7, 6, - 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 8, 7, 7, 6, 6, - 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 8, 7, 7, 6, 6, 5, - 16, 16, 16, 16, 16, 16, 16, 16, 16, 8, 7, 7, 6, 6, 5, 5, - 16, 16, 16, 16, 16, 16, 16, 16, 8, 7, 7, 6, 6, 5, 5, 4, - 16, 16, 16, 16, 16, 16, 16, 8, 7, 7, 6, 6, 5, 5, 4, 4, - 16, 16, 16, 16, 16, 16, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, - 16, 16, 16, 16, 16, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, - 16, 16, 16, 16, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, - 16, 16, 16, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, - 16, 16, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, - 16, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1})); - -static_assert(CheckPartialPixelZ(HalftileSlope(SLOPE_STEEP_E, CORNER_E), { - 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, - 8, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, - 7, 8, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, - 7, 7, 8, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, - 6, 7, 7, 8, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, - 6, 6, 7, 7, 8, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, - 5, 6, 6, 7, 7, 8, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, - 5, 5, 6, 6, 7, 7, 8, 16, 16, 16, 16, 16, 16, 16, 16, 16, - 4, 5, 5, 6, 6, 7, 7, 8, 16, 16, 16, 16, 16, 16, 16, 16, - 4, 4, 5, 5, 6, 6, 7, 7, 8, 16, 16, 16, 16, 16, 16, 16, - 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 16, 16, 16, 16, 16, 16, - 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 16, 16, 16, 16, 16, - 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 16, 16, 16, 16, - 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 16, 16, 16, - 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 16, 16, - 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 16})); - -static_assert(CheckPartialPixelZ(HalftileSlope(SLOPE_STEEP_S, CORNER_S), { - 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, - 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 16, - 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 16, 16, - 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 16, 16, 16, - 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 16, 16, 16, 16, - 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 16, 16, 16, 16, 16, - 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 16, 16, 16, 16, 16, 16, - 4, 4, 5, 5, 6, 6, 7, 7, 8, 16, 16, 16, 16, 16, 16, 16, - 4, 5, 5, 6, 6, 7, 7, 8, 16, 16, 16, 16, 16, 16, 16, 16, - 5, 5, 6, 6, 7, 7, 8, 16, 16, 16, 16, 16, 16, 16, 16, 16, - 5, 6, 6, 7, 7, 8, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, - 6, 6, 7, 7, 8, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, - 6, 7, 7, 8, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, - 7, 7, 8, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, - 7, 8, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, - 8, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16})); - -static_assert(CheckPartialPixelZ(HalftileSlope(SLOPE_STEEP_W, CORNER_W), { - 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 0, - 16, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, - 16, 16, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, - 16, 16, 16, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, - 16, 16, 16, 16, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, - 16, 16, 16, 16, 16, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, - 16, 16, 16, 16, 16, 16, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, - 16, 16, 16, 16, 16, 16, 16, 8, 7, 7, 6, 6, 5, 5, 4, 4, - 16, 16, 16, 16, 16, 16, 16, 16, 8, 7, 7, 6, 6, 5, 5, 4, - 16, 16, 16, 16, 16, 16, 16, 16, 16, 8, 7, 7, 6, 6, 5, 5, - 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 8, 7, 7, 6, 6, 5, - 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 8, 7, 7, 6, 6, - 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 8, 7, 7, 6, - 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 8, 7, 7, - 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 8, 7, - 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 8})); diff --git a/src/tests/math_func.cpp b/src/tests/math_func.cpp new file mode 100644 index 0000000000..0e58b79e42 --- /dev/null +++ b/src/tests/math_func.cpp @@ -0,0 +1,77 @@ +/* + * This file is part of OpenTTD. + * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. + * OpenTTD 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 General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see . + */ + +/** @file math_func_test.cpp Test functionality from core/math_func. */ + +#include "../stdafx.h" + +#include "../3rdparty/catch2/catch.hpp" + +#include "../core/math_func.hpp" + +TEST_CASE("LeastCommonMultipleTest - Zero") +{ + CHECK(0 == LeastCommonMultiple(0, 0)); + CHECK(0 == LeastCommonMultiple(0, 600)); + CHECK(0 == LeastCommonMultiple(600, 0)); +} + +TEST_CASE("LeastCommonMultipleTest - FindLCM") +{ + CHECK(25 == LeastCommonMultiple(5, 25)); + CHECK(25 == LeastCommonMultiple(25, 5)); + CHECK(130 == LeastCommonMultiple(5, 26)); + CHECK(130 == LeastCommonMultiple(26, 5)); +} + +TEST_CASE("GreatestCommonDivisorTest - Negative") +{ + CHECK(4 == GreatestCommonDivisor(4, -52)); + // CHECK(3 == GreatestCommonDivisor(-27, 6)); // error - returns -3 +} + +TEST_CASE("GreatestCommonDivisorTest - Zero") +{ + CHECK(27 == GreatestCommonDivisor(0, 27)); + CHECK(27 == GreatestCommonDivisor(27, 0)); +} + +TEST_CASE("GreatestCommonDivisorTest - FindGCD") +{ + CHECK(5 == GreatestCommonDivisor(5, 25)); + CHECK(5 == GreatestCommonDivisor(25, 5)); + CHECK(1 == GreatestCommonDivisor(7, 27)); + CHECK(1 == GreatestCommonDivisor(27, 7)); +} + +TEST_CASE("DivideApproxTest - Negative") +{ + CHECK(-2 == DivideApprox(-5, 2)); + CHECK(2 == DivideApprox(-5, -2)); + CHECK(-1 == DivideApprox(-66, 80)); +} + +TEST_CASE("DivideApproxTest, Divide") +{ + CHECK(2 == DivideApprox(5, 2)); + CHECK(3 == DivideApprox(80, 30)); + CHECK(3 == DivideApprox(8, 3)); + CHECK(0 == DivideApprox(3, 8)); +} + +TEST_CASE("IntSqrtTest - Zero") +{ + CHECK(0 == IntSqrt(0)); +} + +TEST_CASE("IntSqrtTest - FindSqRt") +{ + CHECK(5 == IntSqrt(25)); + CHECK(10 == IntSqrt(100)); + CHECK(9 == IntSqrt(88)); + CHECK(1696 == IntSqrt(2876278)); +} diff --git a/src/tests/test_main.cpp b/src/tests/test_main.cpp new file mode 100644 index 0000000000..85649aea01 --- /dev/null +++ b/src/tests/test_main.cpp @@ -0,0 +1,29 @@ +/* + * This file is part of OpenTTD. + * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. + * OpenTTD 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 General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see . + */ + +/** @file test_main.cpp Entry point for all the unit tests. */ + +#include "../stdafx.h" + +#include +#include + +#define CATCH_CONFIG_MAIN +#define DO_NOT_USE_WMAIN +#include "../3rdparty/catch2/catch.hpp" + +void CDECL error(const char *s, ...) +{ + va_list va; + char buffer[1024]; + + va_start(va, s); + vsnprintf(buffer, 1024, s, va); + va_end(va); + + CATCH_RUNTIME_ERROR(buffer); +}