1
0
mirror of https://github.com/OpenTTD/OpenTTD.git synced 2025-08-19 20:49:11 +00:00

Fix: crash when window can't be placed on low resolution screens. (#10932)

Co-authored-by: Jonathan G Rennison <j.g.rennison@gmail.com>
This commit is contained in:
Patric Stout
2023-06-04 17:39:57 +02:00
committed by GitHub
parent c43a23cea8
commit 0f3dd9c796
3 changed files with 38 additions and 2 deletions

View File

@@ -120,3 +120,13 @@ TEST_CASE("ClampTo")
/* max uint64_t gets clamped to max int64_t. */
CHECK(std::numeric_limits<int64_t>::max() == ClampTo<int64_t>(std::numeric_limits<uint64_t>::max()));
}
TEST_CASE("SoftClamp")
{
/* Special behaviour of soft clamp returning the average of min/max when min is higher than max. */
CHECK(1250 == SoftClamp(0, 1500, 1000));
int million = 1000 * 1000;
CHECK(1250 * million == SoftClamp(0, 1500 * million, 1000 * million));
CHECK(0 == SoftClamp(0, 1500 * million, -1500 * million));
}