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/>.
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")
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). */
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. */
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);
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. */
50 CHECK(HaveDParamChanged(backup
) == false);