OpenTTD Source 20250205-master-gfd85ab1e2c
enum_over_optimisation.cpp
Go to the documentation of this file.
1/*
2 * This file is part of OpenTTD.
3 * 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.
4 * 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.
5 * 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 <http://www.gnu.org/licenses/>.
6 */
7
14#include "../stdafx.h"
15
16#include "../3rdparty/catch2/catch.hpp"
17
18enum TestEnum : int8_t {
19 ZERO,
20 ONE,
21 TWO
22};
23
24TEST_CASE("EnumOverOptimisation_BoundsCheck")
25{
26 TestEnum negative_one = static_cast<TestEnum>(-1);
27 CHECK(negative_one < ZERO);
28
29 TestEnum three = static_cast<TestEnum>(3);
30 CHECK(TWO < three);
31}