78 Commits

Author SHA1 Message Date
Marino Rottier 45ff80d890 Refactor widget state to single storage model (#26443)
* Allow flag/bitmask coexistence in readers

* Add factory helpers and bulk setters for per-widget flags

* Switch coexistence from OR-both to per-window opt-in

* Migrate seven small windows to per-widget flags

* Migrate seven more windows to per-widget flags

* Migrate Cheats, MapGen and Footpath to per-widget flags

* Fix #26421: scenery tab highlight wraps when there are 64+ groups

* Migrate Ride window to per-widget flags

* Migrate ride and maze construction windows to per-widget flags

* Migrate six more windows to per-widget flags

* Migrate Banner, EditorScenarioOptions and RideList to per-widget flags

* Migrate SceneryScatter and LoadSave to per-widget flags

* Migrate EditorObjectSelection, GameBottomToolbar, Guest, Map, NewRide and Park to per-widget flags

* Migrate TopToolbar, TrackList, Research, Player and Options to per-widget flags

* Opt in remaining windows to per-widget flags

* Narrow getters and setters to per-widget flags

* Remove bitmask fields and useWidgetFlags switch

* Restore switch statements for tab/density pressed state

* Add makeHoldableSpinnerWidgets to drop per-page loops

* Update tests for per-widget flag storage

* Add changelog entry for #26421

* Reword narrative-tense comments from the migration

* Fix clang-format violations

* Remove dead holdable-widget tables from Park and Finances
2026-04-28 09:26:02 +02:00
Michał Janiszewski 0da634d6e7 Fix #26310: crash when multiple subscribers register for the same event (#26315)
The scripting engine's `ExecutePluginCall` by default frees its `JSValue` arguments.
When `HookEngine::Call` iterates over multiple subscribers, the first call would free
the argument, leaving subsequent subscribers with an invalid pointer (use-after-free).

This commit fixes the issue by duplicating the `JSValue` for each subscriber and
ensuring the original value is correctly managed based on the `keepArgsAlive` flag.

A new C++ headless test `ScriptingTests.cpp` is added to verify the fix and prevent
future regressions.
2026-04-05 19:57:00 +02:00
frozensnowy 8ff9efa3a1 Fix #25963: Crash when loading corrupted saves with duplicate entity indices (#25980)
Corrupted RCT1/RCT2 save files may contain entities with duplicate or invalid EntityIndex values and when importing these saves, CreateEntityAt returns nullptr for duplicate indices, causing a null pointer dereference crash in ImportEntityCommonProperties, this sanitises each entity's (entities?) EntityIndex to match its array position, so that CreateEntityAt always succeeds. Added unit tests too for just this case, with a crashing save file.
2026-02-12 13:33:06 +00:00
Duncan add17b14ae Use aliases in cmake to prevent mistakes. Fix g2 dependency mistake (#24213)
Move libopenrct2 cmake to libopenrct2

Revert using aliases for install
2025-04-14 09:45:37 +01:00
Tulio Leao 1ebaac86be Add tests to iterate on all .parkpatch files 2024-08-19 19:52:14 -03:00
Aaron van Geffen 9e206d5528 Remove dependency on StringIds.h from Localisation.h (#22011)
* Remove dependency on StringIds.h from Localisation.h

* Include Language.h in UTF8.cpp for function declarations

* Rename tests/Localisation.cpp to tests/LocalisationTest.cpp
2024-05-10 19:14:05 +00:00
Duncan 1ec62e44bb Add missing string test (#19837) 2023-04-05 21:28:50 +01:00
duncanspumpkin b9ce206044 Move to pretest discovery 2023-03-30 08:31:59 +01:00
duncanspumpkin bde48f0b25 Fix running the tests 2023-03-29 22:05:21 +01:00
duncanspumpkin aee3f17b93 Fix cmake tests compiling 2023-03-29 22:04:13 +01:00
Josh Trzebiatowski 3b82774df1 Rename snake_case methods/classes under tests (#19205)
* Remove snake_case method names in sawyercoding_test.cpp

* Rename sawyercoding_test.cpp to SawyerCodingTest.cpp

* Rename sawyercoding_test.cpp to SawyerCodingTest.cpp
2023-01-18 06:06:54 +00:00
Michał Janiszewski 0f11246a81 Sync cmake version required for tests to main project (#18766)
https://github.com/OpenRCT2/OpenRCT2/blob/b7a1db6e694e2a22f5505f80a79d964eec9d4572/CMakeLists.txt#L2
2022-12-17 18:33:01 +01:00
Michał Janiszewski 1670aa759f Remove support for vendored gtest
Originally implemented only to satisfy the (somewhat dubious) claim of
gtest about the necessity to provide your own copy. The original claim
got removed here:
https://github.com/google/googletest/commit/5437926b2213b1c45c2f34bd858734de90e5fffd
2022-05-09 23:04:53 +02:00
Michał Janiszewski d81b36e16f Update GoogleTest version 2022-05-08 22:22:03 +02:00
ZehMatt cd43cab999 Add tests for EnumMap 2021-07-29 17:07:49 +03:00
Ted John 1523597b50 Fix test failures 2021-02-16 20:25:11 +00:00
Ted John 92fcdfbd9b Fix GCC compiler errors 2020-11-27 18:54:57 +00:00
Hielke Morsink f0c1ea1d37 Split declarations and definitions to improve compile times when editing (#13332)
* Split FileStream declarations and definitions

* Split JobPool declarations and definitions

* Split StringBuilder declarations and definitions

* Split StringReader declarations and definitions

* Split ZoomLevel declarations and definitions

* Fix missing include in FileClassifier.cpp

* Remove pragma once from source files

* Fix missing include in StringBuilder.h

* Update Xcode project

* Fix compilation of tests

Co-authored-by: Michael Steenbeek <m.o.steenbeek@gmail.com>
2020-11-07 12:42:04 +00:00
Tulio Leao bace4d62f8 Specify SYSTEM includes on CMAKE builds 2020-10-09 01:28:34 -03:00
Michael Steenbeek 6b9f83a5a4 Fix compilation on Linux and macOS 2020-09-18 19:46:12 +02:00
Gymnasiast 4ff77ebc35 Split RTL implementations to files; add preprocessor guards 2020-09-18 19:46:12 +02:00
Michał Janiszewski 13842198fa Disable HTTP for targets that don't need it (#12375) 2020-07-25 09:09:15 +02:00
Breno Rodrigues Guimarães ab53ddf59f Avoid fast-forwarding peep into the ride
The code being removed in the patch tries to fast forward a peep into the ride when it is the second peep for a vehicle that is used in pairs. Problem is that funds checking does not happen, so it happens that a peep may pay against its will.
Lets say a rich peep enters in line and a poor peep enters in line right after.
If the price of the ride is such that the rich peep can pay and the poor peep can't, it will be dragged into the ride because funds checking only happened for the first.
The second part of the patch just adjusts we consider the vehicle a full car if the second position is filled.

Add test to verify that a peep is not dragged into a ride it can't pay

This test puts two peeps in a Ferris Wheel. The first peep is rich and the second peep is poor. When they are both in line, the ride price is raised so that the poor peep can't pay.
Make sure the poor peep turns back and leaves the ride.

During development, a mistake in the logic would have broken all rides other than ferris wheels in a way that multiple guests could enter the same car.
Also add a test to make sure that is never broken.
2020-04-25 18:27:33 -03:00
Matt 8243c2b64e Update CMakeLists.txt 2019-10-20 13:49:39 +02:00
Matt 45452ad2c8 Run replay tests with network disabled 2019-08-12 18:04:08 +02:00
Tom Lankhorst 744f2225ed Write platform tests 2019-05-11 13:54:16 +01:00
Matt 15838861cd Add load and save test. 2019-03-02 13:11:08 +01:00
Tom Lankhorst 94758bccf6 Link with platform libraries 2019-02-05 20:17:14 +01:00
Tom Lankhorst ce6e08c633 Introduce SET_CHECK_CXX_FLAGS 2019-02-03 23:32:51 +01:00
Michał Janiszewski f4685f7b94 Add Pathfinding test to CMake 2019-01-02 14:12:51 +00:00
Matt 5cfc06573e Ignore replay test when network is disabled. 2018-12-29 19:23:27 +01:00
Matt ccc3227113 Cleanup. 2018-12-29 19:23:27 +01:00
Michał Janiszewski 05ede45b8e Fix ICU include dirs for tests (#8499) 2018-12-19 23:31:24 +01:00
Ted John f325568a97 Fix non-network builds 2018-06-01 22:47:29 +01:00
Ted John ae81af7965 Fix Linux 2018-06-01 21:28:27 +01:00
Ted John 865bfb7b1b Refactor implementations to different files 2018-06-01 21:27:33 +01:00
Ted John b149c1c4ca Add unit tests for SHA1 hashing 2018-06-01 21:27:33 +01:00
Aaron van Geffen bf1fd997d0 Do not require ICU on MinGW and MSVC targets. 2018-05-22 17:37:07 +02:00
Aaron van Geffen ee8bf9bd4a Use ICU for converting strings to UTF-8 instead of our own tables.
Co-authored-by: Fusxfaranto <fusxfaranto@gmail.com>
2018-05-22 17:37:07 +02:00
Ted John 44764874a3 Add test for ImageImporter 2018-05-13 01:11:56 +01:00
Ted John 1226402d6e Enable localisation tests for cmake 2018-04-18 13:16:20 +02:00
Michał Janiszewski 4d7d7500a1 Fix CMake for test_tile_elements 2018-04-17 20:43:49 +02:00
Hielke Morsink f661d48d90 Add tests for tile_element_wants_path_connection_towards 2018-04-17 20:43:49 +02:00
Michał Janiszewski 22c755f820 Fix tests on travis 2018-04-12 22:06:42 +02:00
Ted John 9a10de7442 Enable integration tests on CI 2018-04-10 13:28:26 +01:00
Michael Steenbeek 755add6c9a Compile localisation folder as C++ 2018-01-06 18:32:25 +01:00
Michael Steenbeek 1a9975d683 Compile util and cheats as C++ 2017-12-14 10:03:21 +01:00
Michael Steenbeek 6dc49d643a Compile files in base dir as C++ 2017-12-13 08:03:48 +01:00
Ted John a737848e8e Remove old C decoding functions and fix tests 2017-10-22 16:21:13 +02:00
Michał Janiszewski e01cd0fd40 Use googletest with google/googletest#1045 2017-10-10 22:26:35 +02:00