Add: Overlay cargo icon in vehicle/depot list when holding shift+ctrl. (#12938)
[openttd-github.git] / src / tests / strings_func.cpp
blobf82cdd92becba1016a8945dae26548a60a3bd9d9
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 */
8 /** @file strings_func.cpp Test functionality from strings_func. */
10 #include "../stdafx.h"
12 #include "../3rdparty/catch2/catch.hpp"
14 #include "../strings_func.h"
16 TEST_CASE("HaveDParamChanged")
18 SetDParam(0, 0);
19 SetDParamStr(1, "some string");
21 std::vector<StringParameterData> backup;
22 CopyOutDParam(backup, 2);
24 CHECK(HaveDParamChanged(backup) == false);
26 /* A different parameter 0 (both string and numeric). */
27 SetDParam(0, 1);
28 CHECK(HaveDParamChanged(backup) == true);
30 SetDParamStr(0, "some other string");
31 CHECK(HaveDParamChanged(backup) == true);
33 /* Back to the original state, nothing should have changed. */
34 SetDParam(0, 0);
35 CHECK(HaveDParamChanged(backup) == false);
37 /* A different parameter 1 (both string and numeric). */
38 SetDParamStr(1, "some other string");
39 CHECK(HaveDParamChanged(backup) == true);
41 SetDParam(1, 0);
42 CHECK(HaveDParamChanged(backup) == true);
44 /* Back to the original state, nothing should have changed. */
45 SetDParamStr(1, "some string");
46 CHECK(HaveDParamChanged(backup) == false);
48 /* Changing paramter 2 should not have any effect, as the backup is only 2 long. */
49 SetDParam(2, 3);
50 CHECK(HaveDParamChanged(backup) == false);