|
OpenTTD Source
14.0-beta3
|
Go to the documentation of this file.
10 #include "../stdafx.h"
12 #include "../3rdparty/catch2/catch.hpp"
16 #include "../window_gui.h"
31 TEST_CASE(
"WindowDesc - ini_key uniqueness")
33 std::set<std::string> seen;
37 if (window_desc->ini_key ==
nullptr)
continue;
39 CAPTURE(window_desc->ini_key);
40 CHECK((seen.find(window_desc->ini_key) == std::end(seen)));
42 seen.insert(window_desc->ini_key);
46 TEST_CASE(
"WindowDesc - ini_key validity")
50 bool has_inikey = window_desc->
ini_key !=
nullptr;
51 bool has_widget = std::any_of(window_desc->
nwid_begin, window_desc->
nwid_end, [](
const NWidgetPart &part) { return part.type == WWT_DEFSIZEBOX || part.type == WWT_STICKYBOX; });
53 INFO(fmt::format(
"{}:{}", window_desc->
file, window_desc->
line));
57 CHECK((has_widget == has_inikey));
70 for (; nwid_begin < nwid_end; ++nwid_begin) {
77 TEST_CASE(
"WindowDesc - NWidgetParts properly closed")
81 INFO(fmt::format(
"{}:{}", window_desc->
file, window_desc->
line));
90 INFO(fmt::format(
"{}:{}", window_desc->
file, window_desc->
line));
93 std::unique_ptr<NWidgetBase> root =
nullptr;
96 CHECK((root !=
nullptr));
const int line
Source line of this definition.
const NWidgetPart * nwid_end
Ending of nested widget parts describing the window.
High level window description.
const char * ini_key
Key to store window defaults in openttd.cfg. nullptr if nothing shall be stored.
static bool IsNWidgetTreeClosed(const NWidgetPart *nwid_begin, const NWidgetPart *nwid_end)
Test if a NWidgetTree is properly closed, meaning the number of container-type parts matches the numb...
std::vector< WindowDesc * > * _window_descs
List of WindowDescs.
Singleton class to set up the mock environemnt once.
const char *const file
Source file of this definition.
const NWidgetPart * nwid_begin
Beginning of nested widget parts describing the window.