OpenTTD Source 20241224-master-gee860a5c8e
test_window_desc.cpp File Reference

Test WindowDescs for valid widget parts. More...

#include "../stdafx.h"
#include "../3rdparty/catch2/catch.hpp"
#include "mock_environment.h"
#include "../window_gui.h"

Go to the source code of this file.

Data Structures

class  WindowDescTestsFixture
 

Functions

 TEST_CASE ("WindowDesc - ini_key uniqueness")
 
 TEST_CASE ("WindowDesc - ini_key validity")
 
static bool IsNWidgetTreeClosed (std::span< const NWidgetPart > nwid_parts)
 Test if a NWidgetTree is properly closed, meaning the number of container-type parts matches the number of EndContainer() parts.
 
 TEST_CASE ("WindowDesc - NWidgetParts properly closed")
 
 TEST_CASE_METHOD (WindowDescTestsFixture, "WindowDesc - NWidgetPart validity")
 

Variables

std::vector< WindowDesc * > * _window_descs
 List of WindowDescs.
 

Detailed Description

Test WindowDescs for valid widget parts.

Definition in file test_window_desc.cpp.

Function Documentation

◆ IsNWidgetTreeClosed()

static bool IsNWidgetTreeClosed ( std::span< const NWidgetPart nwid_parts)
static

Test if a NWidgetTree is properly closed, meaning the number of container-type parts matches the number of EndContainer() parts.

Parameters
nwid_partsSpan of nested widget parts.
Returns
True iff nested tree is properly closed.

Definition at line 66 of file test_window_desc.cpp.

References IsContainerWidgetType(), and WPT_ENDCONTAINER.

◆ TEST_CASE() [1/3]

TEST_CASE ( "WindowDesc - ini_key uniqueness"  )

Definition at line 31 of file test_window_desc.cpp.

◆ TEST_CASE() [2/3]

TEST_CASE ( "WindowDesc - ini_key validity"  )

Definition at line 46 of file test_window_desc.cpp.

◆ TEST_CASE() [3/3]

TEST_CASE ( "WindowDesc - NWidgetParts properly closed"  )

Definition at line 76 of file test_window_desc.cpp.

◆ TEST_CASE_METHOD()

TEST_CASE_METHOD ( WindowDescTestsFixture  ,
"WindowDesc - NWidgetPart validity"   
)

Definition at line 85 of file test_window_desc.cpp.

Variable Documentation

◆ _window_descs

std::vector<WindowDesc*>* _window_descs
extern

List of WindowDescs.

Defined in window.cpp but not exposed as this unit-test is the only other place that needs it. WindowDesc is a self-registering class so all WindowDescs will be included in the list.

List of WindowDescs.

This is a pointer to ensure initialisation order with the various static WindowDesc instances.

Definition at line 99 of file window.cpp.

Referenced by WindowDesc::LoadFromConfig(), WindowDesc::SaveToConfig(), and WindowDesc::WindowDesc().