OpenTTD Source: src/tests/landscape_partial_pixel_z.cpp File Reference

OpenTTD Source 15.3

Functions
landscape_partial_pixel_z.cpp File Reference

Tests for consistency/validity of the results of GetPartialPixelZ. More...

`#include "../stdafx.h"`
`#include "../3rdparty/catch2/catch.hpp"`
`#include "../landscape.h"`
`#include "../slope_func.h"`
`#include "../safeguards.h"`

Go to the source code of this file.

## Functions
bool | CheckPartialPixelZSlopeAddition (Slope slope_expected, Slope slope_a, Slope slope_b)
| Check whether the addition of two slope's GetPartialPixelZ values results in the GetPartialPixelZ values of the expected slope.
| TEST_CASE ("PartialPixelSlopeAdditionTest - A one corner slope, plus the opposite three corner slope results in a flat but elevated slope")
| TEST_CASE ("PartialPixelSlopeAdditionTest - Diagonal slopes with their opposite slope result in a flat but elevated slope")
| TEST_CASE ("PartialPixelSlopeAdditionTest - Half tile slopes with their opposite half tile slope result in a flat but elevated slope")
| TEST_CASE ("PartialPixelSlopeAdditionTest - Two opposite one corner slopes result in the two corner slope with opposite corners")
| TEST_CASE ("PartialPixelSlopeAdditionTest - A steep slope is a one corner slope on top of a three corner slope")
| TEST_CASE ("PartialPixelSlopeAdditionTest - A half tile steep slope is a one corner half tile on top of a three corner slope")
bool | CheckPartialPixelZ (Slope slope, const std::array< int, TILE_SIZE *TILE_SIZE > &expected)
| Check whether the partial pixel Z values are the expected values.
| TEST_CASE ("PartialPixelTest - One corner up slopes - SLOPE_N")
| TEST_CASE ("PartialPixelTest - One corner up slopes - SLOPE_E")
| TEST_CASE ("PartialPixelTest - One corner up slopes - SLOPE_S")
| TEST_CASE ("PartialPixelTest - One corner up slopes - SLOPE_W")
| TEST_CASE ("PartialPixelTest - Two corner up, diagonal slopes - SLOPE_NE")
| TEST_CASE ("PartialPixelTest - Two corner up, diagonal slopes - SLOPE_SE")
| TEST_CASE ("PartialPixelTest - Two corner up, diagonal slopes - SLOPE_SW")
| TEST_CASE ("PartialPixelTest - Two corner up, diagonal slopes - SLOPE_NW")
| TEST_CASE ("PartialPixelTest - Two opposite corner up slopes - SLOPE_NS")
| TEST_CASE ("PartialPixelTest - Two opposite corner up slopes - SLOPE_EW")
| TEST_CASE ("PartialPixelTest - Three corner up slopes - SLOPE_ENW")
| TEST_CASE ("PartialPixelTest - Three corner up slopes - SLOPE_SEN")
| TEST_CASE ("PartialPixelTest - Three corner up slopes - SLOPE_WSE")
| TEST_CASE ("PartialPixelTest - Three corner up slopes - SLOPE_NWS")
| TEST_CASE ("PartialPixelTest - Normal half tile slopes - SLOPE/CORNER_N")
| TEST_CASE ("PartialPixelTest - Normal half tile slopes - SLOPE/CORNER_E")
| TEST_CASE ("PartialPixelTest - Normal half tile slopes - SLOPE/CORNER_S")
| TEST_CASE ("PartialPixelTest - Normal half tile slopes - SLOPE/CORNER_W")
| TEST_CASE ("PartialPixelTest - Steep slopes - SLOPE_STEEP_N")
| TEST_CASE ("PartialPixelTest - Steep slopes - SLOPE_STEEP_E")
| TEST_CASE ("PartialPixelTest - Steep slopes - SLOPE_STEEP_S")
| TEST_CASE ("PartialPixelTest - Steep slopes - SLOPE_STEEP_W")
| TEST_CASE ("PartialPixelTest - Half tile on top of steep slopes - SLOPE_STEEP/CORNER_N")
| TEST_CASE ("PartialPixelTest - Half tile on top of steep slopes - SLOPE_STEEP/CORNER_E")
| TEST_CASE ("PartialPixelTest - Half tile on top of steep slopes - SLOPE_STEEP/CORNER_S")
| TEST_CASE ("PartialPixelTest - Half tile on top of steep slopes - SLOPE_STEEP/CORNER_W")

## Detailed Description

Tests for consistency/validity of the results of GetPartialPixelZ.

Definition in file landscape_partial_pixel_z.cpp.

## Function Documentation

## ◆ CheckPartialPixelZ()

bool CheckPartialPixelZ | ( | Slope | slope,
|  | const std::array< int, TILE_SIZE *TILE_SIZE > & | expected
| ) |  |

Check whether the partial pixel Z values are the expected values.

The arrays are as if the map is rotated 45 degrees counterclockwise.

Parameters

  slope | The slope that is to be checked.
  expected | The expect partial pixels Z values.

Returns
  True iff at all GetPartialPixelZ results are the same as the expected Z-coordinates.

Definition at line 90 of file landscape_partial_pixel_z.cpp.

References GB(), and GetPartialPixelZ().

## ◆ CheckPartialPixelZSlopeAddition()

bool CheckPartialPixelZSlopeAddition | ( | Slope | slope_expected,
|  | Slope | slope_a,
|  | Slope | slope_b
| ) |  |

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.

Parameters

  slope_expected | The slope that is expected.
  slope_a | The first slope of the addition.
  slope_b | The second slope of the addition.

Returns
  True iff at all GetPartialPixelZ results are the same for each sub-tile position.

Definition at line 28 of file landscape_partial_pixel_z.cpp.

References GetPartialPixelZ(), and TILE_SIZE.

## ◆ TEST_CASE() [1/32]

TEST_CASE | ( | "PartialPixelSlopeAdditionTest - A half tile steep slope is a one corner half tile on top of a three corner slope" |  | ) |

Definition at line 75 of file landscape_partial_pixel_z.cpp.

## ◆ TEST_CASE() [2/32]

TEST_CASE | ( | "PartialPixelSlopeAdditionTest - A one corner | slope,
|  | plus the opposite three corner slope results in a flat but elevated slope" |
| ) |  |

Definition at line 41 of file landscape_partial_pixel_z.cpp.

## ◆ TEST_CASE() [3/32]

TEST_CASE | ( | "PartialPixelSlopeAdditionTest - A steep slope is a one corner slope on top of a three corner slope" |  | ) |

Definition at line 67 of file landscape_partial_pixel_z.cpp.

## ◆ TEST_CASE() [4/32]

TEST_CASE | ( | "PartialPixelSlopeAdditionTest - Diagonal slopes with their opposite slope result in a flat but elevated slope" |  | ) |

Definition at line 49 of file landscape_partial_pixel_z.cpp.

## ◆ TEST_CASE() [5/32]

TEST_CASE | ( | "PartialPixelSlopeAdditionTest - Half tile slopes with their opposite half tile slope result in a flat but elevated slope" |  | ) |

Definition at line 55 of file landscape_partial_pixel_z.cpp.

## ◆ TEST_CASE() [6/32]

TEST_CASE | ( | "PartialPixelSlopeAdditionTest - Two opposite one corner slopes result in the two corner slope with opposite corners" |  | ) |

Definition at line 61 of file landscape_partial_pixel_z.cpp.

## ◆ TEST_CASE() [7/32]

TEST_CASE | ( | "PartialPixelTest - Half tile on top of steep slopes - SLOPE_STEEP/CORNER_E" |  | ) |

Definition at line 582 of file landscape_partial_pixel_z.cpp.

## ◆ TEST_CASE() [8/32]

TEST_CASE | ( | "PartialPixelTest - Half tile on top of steep slopes - SLOPE_STEEP/CORNER_N" |  | ) |

Definition at line 561 of file landscape_partial_pixel_z.cpp.

## ◆ TEST_CASE() [9/32]

TEST_CASE | ( | "PartialPixelTest - Half tile on top of steep slopes - SLOPE_STEEP/CORNER_S" |  | ) |

Definition at line 603 of file landscape_partial_pixel_z.cpp.

## ◆ TEST_CASE() [10/32]

TEST_CASE | ( | "PartialPixelTest - Half tile on top of steep slopes - SLOPE_STEEP/CORNER_W" |  | ) |

Definition at line 624 of file landscape_partial_pixel_z.cpp.

## ◆ TEST_CASE() [11/32]

TEST_CASE | ( | "PartialPixelTest - Normal half tile slopes - SLOPE/CORNER_E" |  | ) |

Definition at line 414 of file landscape_partial_pixel_z.cpp.

## ◆ TEST_CASE() [12/32]

TEST_CASE | ( | "PartialPixelTest - Normal half tile slopes - SLOPE/CORNER_N" |  | ) |

Definition at line 393 of file landscape_partial_pixel_z.cpp.

## ◆ TEST_CASE() [13/32]

TEST_CASE | ( | "PartialPixelTest - Normal half tile slopes - SLOPE/CORNER_S" |  | ) |

Definition at line 435 of file landscape_partial_pixel_z.cpp.

## ◆ TEST_CASE() [14/32]

TEST_CASE | ( | "PartialPixelTest - Normal half tile slopes - SLOPE/CORNER_W" |  | ) |

Definition at line 456 of file landscape_partial_pixel_z.cpp.

## ◆ TEST_CASE() [15/32]

TEST_CASE | ( | "PartialPixelTest - One corner up slopes - SLOPE_E" |  | ) |

Definition at line 120 of file landscape_partial_pixel_z.cpp.

## ◆ TEST_CASE() [16/32]

TEST_CASE | ( | "PartialPixelTest - One corner up slopes - SLOPE_N" |  | ) |

Definition at line 99 of file landscape_partial_pixel_z.cpp.

## ◆ TEST_CASE() [17/32]

TEST_CASE | ( | "PartialPixelTest - One corner up slopes - SLOPE_S" |  | ) |

Definition at line 141 of file landscape_partial_pixel_z.cpp.

## ◆ TEST_CASE() [18/32]

TEST_CASE | ( | "PartialPixelTest - One corner up slopes - SLOPE_W" |  | ) |

Definition at line 162 of file landscape_partial_pixel_z.cpp.

## ◆ TEST_CASE() [19/32]

TEST_CASE | ( | "PartialPixelTest - Steep slopes - SLOPE_STEEP_E" |  | ) |

Definition at line 498 of file landscape_partial_pixel_z.cpp.

## ◆ TEST_CASE() [20/32]

TEST_CASE | ( | "PartialPixelTest - Steep slopes - SLOPE_STEEP_N" |  | ) |

Definition at line 477 of file landscape_partial_pixel_z.cpp.

## ◆ TEST_CASE() [21/32]

TEST_CASE | ( | "PartialPixelTest - Steep slopes - SLOPE_STEEP_S" |  | ) |

Definition at line 519 of file landscape_partial_pixel_z.cpp.

## ◆ TEST_CASE() [22/32]

TEST_CASE | ( | "PartialPixelTest - Steep slopes - SLOPE_STEEP_W" |  | ) |

Definition at line 540 of file landscape_partial_pixel_z.cpp.

## ◆ TEST_CASE() [23/32]

TEST_CASE | ( | "PartialPixelTest - Three corner up slopes - SLOPE_ENW" |  | ) |

Definition at line 309 of file landscape_partial_pixel_z.cpp.

## ◆ TEST_CASE() [24/32]

TEST_CASE | ( | "PartialPixelTest - Three corner up slopes - SLOPE_NWS" |  | ) |

Definition at line 372 of file landscape_partial_pixel_z.cpp.

## ◆ TEST_CASE() [25/32]

TEST_CASE | ( | "PartialPixelTest - Three corner up slopes - SLOPE_SEN" |  | ) |

Definition at line 330 of file landscape_partial_pixel_z.cpp.

## ◆ TEST_CASE() [26/32]

TEST_CASE | ( | "PartialPixelTest - Three corner up slopes - SLOPE_WSE" |  | ) |

Definition at line 351 of file landscape_partial_pixel_z.cpp.

## ◆ TEST_CASE() [27/32]

TEST_CASE | ( | "PartialPixelTest - Two corner | up,
|  | diagonal slopes - SLOPE_NE" |
| ) |  |

Definition at line 183 of file landscape_partial_pixel_z.cpp.

## ◆ TEST_CASE() [28/32]

TEST_CASE | ( | "PartialPixelTest - Two corner | up,
|  | diagonal slopes - SLOPE_NW" |
| ) |  |

Definition at line 246 of file landscape_partial_pixel_z.cpp.

## ◆ TEST_CASE() [29/32]

TEST_CASE | ( | "PartialPixelTest - Two corner | up,
|  | diagonal slopes - SLOPE_SE" |
| ) |  |

Definition at line 204 of file landscape_partial_pixel_z.cpp.

## ◆ TEST_CASE() [30/32]

TEST_CASE | ( | "PartialPixelTest - Two corner | up,
|  | diagonal slopes - SLOPE_SW" |
| ) |  |

Definition at line 225 of file landscape_partial_pixel_z.cpp.

## ◆ TEST_CASE() [31/32]

TEST_CASE | ( | "PartialPixelTest - Two opposite corner up slopes - SLOPE_EW" |  | ) |

Definition at line 288 of file landscape_partial_pixel_z.cpp.

## ◆ TEST_CASE() [32/32]

TEST_CASE | ( | "PartialPixelTest - Two opposite corner up slopes - SLOPE_NS" |  | ) |

Definition at line 267 of file landscape_partial_pixel_z.cpp.