mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2026-06-06 08:42:35 +00:00
Reformat code with clang format
This commit is contained in:
@@ -1,16 +1,15 @@
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
#include <catch2/matchers/catch_matchers_floating_point.hpp>
|
||||
#include <catch2/generators/catch_generators.hpp>
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "Game/IW4/GameIW4.h"
|
||||
#include "Game/IW4/AssetLoaders/AssetLoaderMenuList.h"
|
||||
#include "Game/IW4/GameIW4.h"
|
||||
#include "Mock/MockAssetLoadingManager.h"
|
||||
#include "Mock/MockSearchPath.h"
|
||||
#include "Parsing/Menu/MenuFileReader.h"
|
||||
#include "Utils/MemoryManager.h"
|
||||
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
#include <catch2/generators/catch_generators.hpp>
|
||||
#include <catch2/matchers/catch_matchers_floating_point.hpp>
|
||||
#include <string>
|
||||
|
||||
using namespace menu;
|
||||
using namespace IW4;
|
||||
using namespace std::literals;
|
||||
@@ -18,71 +17,71 @@ using namespace Catch::Matchers;
|
||||
|
||||
namespace test::game::iw4::menu::parsing::it
|
||||
{
|
||||
class MenuParsingItHelper
|
||||
{
|
||||
static constexpr const char* DEFAULT_ASSET_NAME = "test.txt";
|
||||
class MenuParsingItHelper
|
||||
{
|
||||
static constexpr const char* DEFAULT_ASSET_NAME = "test.txt";
|
||||
|
||||
Zone m_zone;
|
||||
MockSearchPath m_search_path;
|
||||
MockAssetLoadingManager m_manager;
|
||||
AssetLoaderMenuList m_asset_loader;
|
||||
Zone m_zone;
|
||||
MockSearchPath m_search_path;
|
||||
MockAssetLoadingManager m_manager;
|
||||
AssetLoaderMenuList m_asset_loader;
|
||||
|
||||
public:
|
||||
MenuParsingItHelper()
|
||||
: m_zone("MockZone", 0, &g_GameIW4),
|
||||
m_manager(&m_zone, &m_search_path)
|
||||
{
|
||||
}
|
||||
public:
|
||||
MenuParsingItHelper()
|
||||
: m_zone("MockZone", 0, &g_GameIW4),
|
||||
m_manager(&m_zone, &m_search_path)
|
||||
{
|
||||
}
|
||||
|
||||
void AddFile(std::string fileName, std::string data)
|
||||
{
|
||||
m_search_path.AddFileData(std::move(fileName), std::move(data));
|
||||
}
|
||||
void AddFile(std::string fileName, std::string data)
|
||||
{
|
||||
m_search_path.AddFileData(std::move(fileName), std::move(data));
|
||||
}
|
||||
|
||||
void AddFile(std::string data)
|
||||
{
|
||||
AddFile(DEFAULT_ASSET_NAME, std::move(data));
|
||||
}
|
||||
void AddFile(std::string data)
|
||||
{
|
||||
AddFile(DEFAULT_ASSET_NAME, std::move(data));
|
||||
}
|
||||
|
||||
Material* AddMaterial(const std::string& name)
|
||||
{
|
||||
auto* material = m_zone.GetMemory()->Create<Material>();
|
||||
material->info.name = m_zone.GetMemory()->Dup(name.c_str());
|
||||
Material* AddMaterial(const std::string& name)
|
||||
{
|
||||
auto* material = m_zone.GetMemory()->Create<Material>();
|
||||
material->info.name = m_zone.GetMemory()->Dup(name.c_str());
|
||||
|
||||
m_manager.MockAddAvailableDependency(ASSET_TYPE_MATERIAL, name, material);
|
||||
m_manager.MockAddAvailableDependency(ASSET_TYPE_MATERIAL, name, material);
|
||||
|
||||
return material;
|
||||
}
|
||||
return material;
|
||||
}
|
||||
|
||||
bool RunIntegrationTest()
|
||||
{
|
||||
return m_asset_loader.LoadFromRaw(DEFAULT_ASSET_NAME, &m_search_path, m_zone.GetMemory(), &m_manager, &m_zone);
|
||||
}
|
||||
bool RunIntegrationTest()
|
||||
{
|
||||
return m_asset_loader.LoadFromRaw(DEFAULT_ASSET_NAME, &m_search_path, m_zone.GetMemory(), &m_manager, &m_zone);
|
||||
}
|
||||
|
||||
MenuList* GetMenuListAsset()
|
||||
{
|
||||
const auto addedAsset = m_manager.MockGetAddedAsset(DEFAULT_ASSET_NAME);
|
||||
REQUIRE(addedAsset);
|
||||
REQUIRE(addedAsset->m_type == ASSET_TYPE_MENULIST);
|
||||
MenuList* GetMenuListAsset()
|
||||
{
|
||||
const auto addedAsset = m_manager.MockGetAddedAsset(DEFAULT_ASSET_NAME);
|
||||
REQUIRE(addedAsset);
|
||||
REQUIRE(addedAsset->m_type == ASSET_TYPE_MENULIST);
|
||||
|
||||
return static_cast<MenuList*>(addedAsset->m_ptr);
|
||||
}
|
||||
return static_cast<MenuList*>(addedAsset->m_ptr);
|
||||
}
|
||||
|
||||
menuDef_t* GetMenuAsset(const std::string& menuName)
|
||||
{
|
||||
const auto addedAsset = m_manager.MockGetAddedAsset(menuName);
|
||||
REQUIRE(addedAsset);
|
||||
REQUIRE(addedAsset->m_type == ASSET_TYPE_MENU);
|
||||
menuDef_t* GetMenuAsset(const std::string& menuName)
|
||||
{
|
||||
const auto addedAsset = m_manager.MockGetAddedAsset(menuName);
|
||||
REQUIRE(addedAsset);
|
||||
REQUIRE(addedAsset->m_type == ASSET_TYPE_MENU);
|
||||
|
||||
return static_cast<menuDef_t*>(addedAsset->m_ptr);
|
||||
}
|
||||
};
|
||||
return static_cast<menuDef_t*>(addedAsset->m_ptr);
|
||||
}
|
||||
};
|
||||
|
||||
TEST_CASE("MenuParsingIW4IT: Can convert simple menu without properties", "[parsing][converting][menu][it]")
|
||||
{
|
||||
MenuParsingItHelper helper;
|
||||
TEST_CASE("MenuParsingIW4IT: Can convert simple menu without properties", "[parsing][converting][menu][it]")
|
||||
{
|
||||
MenuParsingItHelper helper;
|
||||
|
||||
helper.AddFile(R"testmenu(
|
||||
helper.AddFile(R"testmenu(
|
||||
{
|
||||
menuDef
|
||||
{
|
||||
@@ -91,27 +90,27 @@ namespace test::game::iw4::menu::parsing::it
|
||||
}
|
||||
)testmenu");
|
||||
|
||||
const auto result = helper.RunIntegrationTest();
|
||||
REQUIRE(result);
|
||||
const auto result = helper.RunIntegrationTest();
|
||||
REQUIRE(result);
|
||||
|
||||
const auto* menuList = helper.GetMenuListAsset();
|
||||
const auto* menu = helper.GetMenuAsset("Hello");
|
||||
const auto* menuList = helper.GetMenuListAsset();
|
||||
const auto* menu = helper.GetMenuAsset("Hello");
|
||||
|
||||
REQUIRE(menuList->menuCount == 1);
|
||||
REQUIRE(menuList->menus);
|
||||
REQUIRE(menuList->menuCount == 1);
|
||||
REQUIRE(menuList->menus);
|
||||
|
||||
REQUIRE(menuList->menus[0] == menu);
|
||||
REQUIRE(menuList->menus[0] == menu);
|
||||
|
||||
REQUIRE(menu->window.name == "Hello"s);
|
||||
REQUIRE(menu->itemCount == 0);
|
||||
REQUIRE(menu->items == nullptr);
|
||||
}
|
||||
REQUIRE(menu->window.name == "Hello"s);
|
||||
REQUIRE(menu->itemCount == 0);
|
||||
REQUIRE(menu->items == nullptr);
|
||||
}
|
||||
|
||||
TEST_CASE("MenuParsingIW4IT: Can convert simple menu", "[parsing][converting][menu][it]")
|
||||
{
|
||||
MenuParsingItHelper helper;
|
||||
TEST_CASE("MenuParsingIW4IT: Can convert simple menu", "[parsing][converting][menu][it]")
|
||||
{
|
||||
MenuParsingItHelper helper;
|
||||
|
||||
helper.AddFile(R"testmenu(
|
||||
helper.AddFile(R"testmenu(
|
||||
#define COOL_STYLE 5
|
||||
#define VISIBILITY_ENABLED 1
|
||||
#define HIDE_STUPID_ELEMENTS 0
|
||||
@@ -170,144 +169,147 @@ namespace test::game::iw4::menu::parsing::it
|
||||
}
|
||||
)testmenu");
|
||||
|
||||
const auto* funnyDogMaterial = helper.AddMaterial("funny_dog.png");
|
||||
const auto* funnyDogMaterial = helper.AddMaterial("funny_dog.png");
|
||||
|
||||
const auto result = helper.RunIntegrationTest();
|
||||
REQUIRE(result);
|
||||
const auto result = helper.RunIntegrationTest();
|
||||
REQUIRE(result);
|
||||
|
||||
const auto* menuList = helper.GetMenuListAsset();
|
||||
const auto* menu = helper.GetMenuAsset("Bla");
|
||||
const auto* menuList = helper.GetMenuListAsset();
|
||||
const auto* menu = helper.GetMenuAsset("Bla");
|
||||
|
||||
REQUIRE(menuList->menuCount == 1);
|
||||
REQUIRE(menuList->menus);
|
||||
REQUIRE(menuList->menuCount == 1);
|
||||
REQUIRE(menuList->menus);
|
||||
|
||||
REQUIRE(menuList->menus[0] == menu);
|
||||
REQUIRE(menuList->menus[0] == menu);
|
||||
|
||||
REQUIRE(menu->window.name == "Bla"s);
|
||||
REQUIRE(menu->fullScreen > 0);
|
||||
REQUIRE(menu->window.staticFlags & WINDOW_FLAG_SCREEN_SPACE);
|
||||
REQUIRE(menu->window.staticFlags & WINDOW_FLAG_DECORATION);
|
||||
REQUIRE_THAT(menu->window.rect.x, WithinRel(420.0f));
|
||||
REQUIRE_THAT(menu->window.rect.y, WithinRel(1337.0f));
|
||||
REQUIRE_THAT(menu->window.rect.w, WithinRel(12.0f));
|
||||
REQUIRE_THAT(menu->window.rect.h, WithinRel(64.0f));
|
||||
REQUIRE(menu->window.rect.horzAlign == 1);
|
||||
REQUIRE(menu->window.rect.vertAlign == 2);
|
||||
REQUIRE(menu->window.style == 5);
|
||||
REQUIRE(menu->window.name == "Bla"s);
|
||||
REQUIRE(menu->fullScreen > 0);
|
||||
REQUIRE(menu->window.staticFlags & WINDOW_FLAG_SCREEN_SPACE);
|
||||
REQUIRE(menu->window.staticFlags & WINDOW_FLAG_DECORATION);
|
||||
REQUIRE_THAT(menu->window.rect.x, WithinRel(420.0f));
|
||||
REQUIRE_THAT(menu->window.rect.y, WithinRel(1337.0f));
|
||||
REQUIRE_THAT(menu->window.rect.w, WithinRel(12.0f));
|
||||
REQUIRE_THAT(menu->window.rect.h, WithinRel(64.0f));
|
||||
REQUIRE(menu->window.rect.horzAlign == 1);
|
||||
REQUIRE(menu->window.rect.vertAlign == 2);
|
||||
REQUIRE(menu->window.style == 5);
|
||||
|
||||
REQUIRE(menu->visibleExp == nullptr);
|
||||
REQUIRE(menu->window.dynamicFlags[0] & WINDOW_FLAG_VISIBLE);
|
||||
REQUIRE(menu->visibleExp == nullptr);
|
||||
REQUIRE(menu->window.dynamicFlags[0] & WINDOW_FLAG_VISIBLE);
|
||||
|
||||
REQUIRE(menu->onOpen != nullptr);
|
||||
REQUIRE(menu->onOpen->eventHandlerCount == 1);
|
||||
REQUIRE(menu->onOpen->eventHandlers[0]->eventType == EventType::EVENT_UNCONDITIONAL);
|
||||
REQUIRE(menu->onOpen->eventHandlers[0]->eventData.unconditionalScript != nullptr);
|
||||
REQUIRE(menu->onOpen->eventHandlers[0]->eventData.unconditionalScript == R"("focusFirst" ; "play" "fart_sound" ; "exec" "wait 1; set r_fullbright 1" ; )"s);
|
||||
REQUIRE(menu->onOpen != nullptr);
|
||||
REQUIRE(menu->onOpen->eventHandlerCount == 1);
|
||||
REQUIRE(menu->onOpen->eventHandlers[0]->eventType == EventType::EVENT_UNCONDITIONAL);
|
||||
REQUIRE(menu->onOpen->eventHandlers[0]->eventData.unconditionalScript != nullptr);
|
||||
REQUIRE(menu->onOpen->eventHandlers[0]->eventData.unconditionalScript
|
||||
== R"("focusFirst" ; "play" "fart_sound" ; "exec" "wait 1; set r_fullbright 1" ; )"s);
|
||||
|
||||
REQUIRE(menu->onClose != nullptr);
|
||||
REQUIRE(menu->onClose->eventHandlerCount == 4);
|
||||
REQUIRE(menu->onClose->eventHandlers[0]->eventType == EventType::EVENT_UNCONDITIONAL);
|
||||
REQUIRE(menu->onClose->eventHandlers[0]->eventData.unconditionalScript != nullptr);
|
||||
REQUIRE(menu->onClose->eventHandlers[0]->eventData.unconditionalScript == R"("setBackground" "cute_cat.jpg" ; )"s);
|
||||
REQUIRE(menu->onClose->eventHandlers[1]->eventType == EventType::EVENT_IF);
|
||||
REQUIRE(menu->onClose->eventHandlers[1]->eventData.conditionalScript != nullptr);
|
||||
REQUIRE(menu->onClose->eventHandlers[1]->eventData.conditionalScript->eventExpression != nullptr);
|
||||
REQUIRE(menu->onClose->eventHandlers[1]->eventData.conditionalScript->eventExpression->numEntries == 5);
|
||||
REQUIRE(menu->onClose->eventHandlers[1]->eventData.conditionalScript->eventExpression->entries[0].type == expressionEntryType::EET_OPERATOR);
|
||||
REQUIRE(menu->onClose->eventHandlers[1]->eventData.conditionalScript->eventExpression->entries[0].data.op == 102); // anynewmappacks
|
||||
REQUIRE(menu->onClose->eventHandlers[1]->eventData.conditionalScript->eventExpression->entries[1].type == expressionEntryType::EET_OPERATOR);
|
||||
REQUIRE(menu->onClose->eventHandlers[1]->eventData.conditionalScript->eventExpression->entries[1].data.op == OP_RIGHTPAREN);
|
||||
REQUIRE(menu->onClose->eventHandlers[1]->eventData.conditionalScript->eventExpression->entries[2].type == expressionEntryType::EET_OPERATOR);
|
||||
REQUIRE(menu->onClose->eventHandlers[1]->eventData.conditionalScript->eventExpression->entries[2].data.op == OP_AND);
|
||||
REQUIRE(menu->onClose->eventHandlers[1]->eventData.conditionalScript->eventExpression->entries[3].type == expressionEntryType::EET_OPERATOR);
|
||||
REQUIRE(menu->onClose->eventHandlers[1]->eventData.conditionalScript->eventExpression->entries[3].data.op == 118); // isreloading
|
||||
REQUIRE(menu->onClose->eventHandlers[1]->eventData.conditionalScript->eventExpression->entries[4].type == expressionEntryType::EET_OPERATOR);
|
||||
REQUIRE(menu->onClose->eventHandlers[1]->eventData.conditionalScript->eventExpression->entries[4].data.op == OP_RIGHTPAREN);
|
||||
REQUIRE(menu->onClose->eventHandlers[1]->eventData.conditionalScript->eventHandlerSet != nullptr);
|
||||
REQUIRE(menu->onClose->eventHandlers[1]->eventData.conditionalScript->eventHandlerSet->eventHandlerCount == 1);
|
||||
REQUIRE(menu->onClose->eventHandlers[1]->eventData.conditionalScript->eventHandlerSet->eventHandlers != nullptr);
|
||||
REQUIRE(menu->onClose->eventHandlers[1]->eventData.conditionalScript->eventHandlerSet->eventHandlers[0] != nullptr);
|
||||
REQUIRE(menu->onClose->eventHandlers[1]->eventData.conditionalScript->eventHandlerSet->eventHandlers[0]->eventType == EventType::EVENT_UNCONDITIONAL);
|
||||
REQUIRE(menu->onClose->eventHandlers[1]->eventData.conditionalScript->eventHandlerSet->eventHandlers[0]->eventData.unconditionalScript == R"("exec" "quit" ; )"s);
|
||||
REQUIRE(menu->onClose->eventHandlers[2]->eventType == EventType::EVENT_ELSE);
|
||||
REQUIRE(menu->onClose->eventHandlers[2]->eventData.elseScript != nullptr);
|
||||
REQUIRE(menu->onClose->eventHandlers[2]->eventData.elseScript->eventHandlerCount == 1);
|
||||
REQUIRE(menu->onClose->eventHandlers[2]->eventData.elseScript->eventHandlers != nullptr);
|
||||
REQUIRE(menu->onClose->eventHandlers[2]->eventData.elseScript->eventHandlers[0] != nullptr);
|
||||
REQUIRE(menu->onClose->eventHandlers[2]->eventData.elseScript->eventHandlers[0]->eventType == EventType::EVENT_UNCONDITIONAL);
|
||||
REQUIRE(menu->onClose->eventHandlers[2]->eventData.elseScript->eventHandlers[0]->eventData.unconditionalScript == R"("uiScript" "startSingleplayer" ; )"s);
|
||||
REQUIRE(menu->onClose->eventHandlers[3]->eventType == EventType::EVENT_UNCONDITIONAL);
|
||||
REQUIRE(menu->onClose->eventHandlers[3]->eventData.unconditionalScript != nullptr);
|
||||
REQUIRE(menu->onClose->eventHandlers[3]->eventData.unconditionalScript == R"("setGameMode" "dm" ; )"s);
|
||||
REQUIRE(menu->onClose != nullptr);
|
||||
REQUIRE(menu->onClose->eventHandlerCount == 4);
|
||||
REQUIRE(menu->onClose->eventHandlers[0]->eventType == EventType::EVENT_UNCONDITIONAL);
|
||||
REQUIRE(menu->onClose->eventHandlers[0]->eventData.unconditionalScript != nullptr);
|
||||
REQUIRE(menu->onClose->eventHandlers[0]->eventData.unconditionalScript == R"("setBackground" "cute_cat.jpg" ; )"s);
|
||||
REQUIRE(menu->onClose->eventHandlers[1]->eventType == EventType::EVENT_IF);
|
||||
REQUIRE(menu->onClose->eventHandlers[1]->eventData.conditionalScript != nullptr);
|
||||
REQUIRE(menu->onClose->eventHandlers[1]->eventData.conditionalScript->eventExpression != nullptr);
|
||||
REQUIRE(menu->onClose->eventHandlers[1]->eventData.conditionalScript->eventExpression->numEntries == 5);
|
||||
REQUIRE(menu->onClose->eventHandlers[1]->eventData.conditionalScript->eventExpression->entries[0].type == expressionEntryType::EET_OPERATOR);
|
||||
REQUIRE(menu->onClose->eventHandlers[1]->eventData.conditionalScript->eventExpression->entries[0].data.op == 102); // anynewmappacks
|
||||
REQUIRE(menu->onClose->eventHandlers[1]->eventData.conditionalScript->eventExpression->entries[1].type == expressionEntryType::EET_OPERATOR);
|
||||
REQUIRE(menu->onClose->eventHandlers[1]->eventData.conditionalScript->eventExpression->entries[1].data.op == OP_RIGHTPAREN);
|
||||
REQUIRE(menu->onClose->eventHandlers[1]->eventData.conditionalScript->eventExpression->entries[2].type == expressionEntryType::EET_OPERATOR);
|
||||
REQUIRE(menu->onClose->eventHandlers[1]->eventData.conditionalScript->eventExpression->entries[2].data.op == OP_AND);
|
||||
REQUIRE(menu->onClose->eventHandlers[1]->eventData.conditionalScript->eventExpression->entries[3].type == expressionEntryType::EET_OPERATOR);
|
||||
REQUIRE(menu->onClose->eventHandlers[1]->eventData.conditionalScript->eventExpression->entries[3].data.op == 118); // isreloading
|
||||
REQUIRE(menu->onClose->eventHandlers[1]->eventData.conditionalScript->eventExpression->entries[4].type == expressionEntryType::EET_OPERATOR);
|
||||
REQUIRE(menu->onClose->eventHandlers[1]->eventData.conditionalScript->eventExpression->entries[4].data.op == OP_RIGHTPAREN);
|
||||
REQUIRE(menu->onClose->eventHandlers[1]->eventData.conditionalScript->eventHandlerSet != nullptr);
|
||||
REQUIRE(menu->onClose->eventHandlers[1]->eventData.conditionalScript->eventHandlerSet->eventHandlerCount == 1);
|
||||
REQUIRE(menu->onClose->eventHandlers[1]->eventData.conditionalScript->eventHandlerSet->eventHandlers != nullptr);
|
||||
REQUIRE(menu->onClose->eventHandlers[1]->eventData.conditionalScript->eventHandlerSet->eventHandlers[0] != nullptr);
|
||||
REQUIRE(menu->onClose->eventHandlers[1]->eventData.conditionalScript->eventHandlerSet->eventHandlers[0]->eventType == EventType::EVENT_UNCONDITIONAL);
|
||||
REQUIRE(menu->onClose->eventHandlers[1]->eventData.conditionalScript->eventHandlerSet->eventHandlers[0]->eventData.unconditionalScript
|
||||
== R"("exec" "quit" ; )"s);
|
||||
REQUIRE(menu->onClose->eventHandlers[2]->eventType == EventType::EVENT_ELSE);
|
||||
REQUIRE(menu->onClose->eventHandlers[2]->eventData.elseScript != nullptr);
|
||||
REQUIRE(menu->onClose->eventHandlers[2]->eventData.elseScript->eventHandlerCount == 1);
|
||||
REQUIRE(menu->onClose->eventHandlers[2]->eventData.elseScript->eventHandlers != nullptr);
|
||||
REQUIRE(menu->onClose->eventHandlers[2]->eventData.elseScript->eventHandlers[0] != nullptr);
|
||||
REQUIRE(menu->onClose->eventHandlers[2]->eventData.elseScript->eventHandlers[0]->eventType == EventType::EVENT_UNCONDITIONAL);
|
||||
REQUIRE(menu->onClose->eventHandlers[2]->eventData.elseScript->eventHandlers[0]->eventData.unconditionalScript
|
||||
== R"("uiScript" "startSingleplayer" ; )"s);
|
||||
REQUIRE(menu->onClose->eventHandlers[3]->eventType == EventType::EVENT_UNCONDITIONAL);
|
||||
REQUIRE(menu->onClose->eventHandlers[3]->eventData.unconditionalScript != nullptr);
|
||||
REQUIRE(menu->onClose->eventHandlers[3]->eventData.unconditionalScript == R"("setGameMode" "dm" ; )"s);
|
||||
|
||||
REQUIRE(menu->onCloseRequest != nullptr);
|
||||
REQUIRE(menu->onCloseRequest->eventHandlerCount == 1);
|
||||
REQUIRE(menu->onCloseRequest->eventHandlers[0]->eventType == EventType::EVENT_UNCONDITIONAL);
|
||||
REQUIRE(menu->onCloseRequest->eventHandlers[0]->eventData.unconditionalScript != nullptr);
|
||||
REQUIRE(menu->onCloseRequest->eventHandlers[0]->eventData.unconditionalScript == R"("play" "nope" ; )"s);
|
||||
REQUIRE(menu->onCloseRequest != nullptr);
|
||||
REQUIRE(menu->onCloseRequest->eventHandlerCount == 1);
|
||||
REQUIRE(menu->onCloseRequest->eventHandlers[0]->eventType == EventType::EVENT_UNCONDITIONAL);
|
||||
REQUIRE(menu->onCloseRequest->eventHandlers[0]->eventData.unconditionalScript != nullptr);
|
||||
REQUIRE(menu->onCloseRequest->eventHandlers[0]->eventData.unconditionalScript == R"("play" "nope" ; )"s);
|
||||
|
||||
REQUIRE(menu->onESC != nullptr);
|
||||
REQUIRE(menu->onESC->eventHandlerCount == 1);
|
||||
REQUIRE(menu->onESC->eventHandlers[0]->eventType == EventType::EVENT_UNCONDITIONAL);
|
||||
REQUIRE(menu->onESC->eventHandlers[0]->eventData.unconditionalScript != nullptr);
|
||||
REQUIRE(menu->onESC->eventHandlers[0]->eventData.unconditionalScript == R"("setColor" "backColor" "1" "0.5" "0.1" "1" ; )"s);
|
||||
REQUIRE(menu->onESC != nullptr);
|
||||
REQUIRE(menu->onESC->eventHandlerCount == 1);
|
||||
REQUIRE(menu->onESC->eventHandlers[0]->eventType == EventType::EVENT_UNCONDITIONAL);
|
||||
REQUIRE(menu->onESC->eventHandlers[0]->eventData.unconditionalScript != nullptr);
|
||||
REQUIRE(menu->onESC->eventHandlers[0]->eventData.unconditionalScript == R"("setColor" "backColor" "1" "0.5" "0.1" "1" ; )"s);
|
||||
|
||||
REQUIRE(menu->window.border == 1);
|
||||
REQUIRE_THAT(menu->window.borderSize, WithinRel(1.25f));
|
||||
REQUIRE_THAT(menu->window.borderSize, WithinRel(1.25));
|
||||
REQUIRE_THAT(menu->window.backColor[0], WithinRel(1.0f));
|
||||
REQUIRE_THAT(menu->window.backColor[1], WithinRel(0.8f));
|
||||
REQUIRE_THAT(menu->window.backColor[2], WithinRel(0.4f));
|
||||
REQUIRE_THAT(menu->window.backColor[3], WithinRel(0.95f));
|
||||
REQUIRE_THAT(menu->window.foreColor[0], WithinRel(0.7f));
|
||||
REQUIRE_THAT(menu->window.foreColor[1], WithinRel(0.0f));
|
||||
REQUIRE_THAT(menu->window.foreColor[2], WithinRel(0.0f));
|
||||
REQUIRE_THAT(menu->window.foreColor[3], WithinRel(0.0f));
|
||||
REQUIRE(menu->window.background == funnyDogMaterial);
|
||||
REQUIRE(menu->window.border == 1);
|
||||
REQUIRE_THAT(menu->window.borderSize, WithinRel(1.25f));
|
||||
REQUIRE_THAT(menu->window.borderSize, WithinRel(1.25));
|
||||
REQUIRE_THAT(menu->window.backColor[0], WithinRel(1.0f));
|
||||
REQUIRE_THAT(menu->window.backColor[1], WithinRel(0.8f));
|
||||
REQUIRE_THAT(menu->window.backColor[2], WithinRel(0.4f));
|
||||
REQUIRE_THAT(menu->window.backColor[3], WithinRel(0.95f));
|
||||
REQUIRE_THAT(menu->window.foreColor[0], WithinRel(0.7f));
|
||||
REQUIRE_THAT(menu->window.foreColor[1], WithinRel(0.0f));
|
||||
REQUIRE_THAT(menu->window.foreColor[2], WithinRel(0.0f));
|
||||
REQUIRE_THAT(menu->window.foreColor[3], WithinRel(0.0f));
|
||||
REQUIRE(menu->window.background == funnyDogMaterial);
|
||||
|
||||
REQUIRE(menu->onKey != nullptr);
|
||||
REQUIRE(menu->onKey->next != nullptr);
|
||||
REQUIRE(menu->onKey->next->next == nullptr);
|
||||
REQUIRE(menu->onKey != nullptr);
|
||||
REQUIRE(menu->onKey->next != nullptr);
|
||||
REQUIRE(menu->onKey->next->next == nullptr);
|
||||
|
||||
const auto keyHandler1 = menu->onKey;
|
||||
const auto keyHandler2 = menu->onKey->next;
|
||||
const auto keyHandler1 = menu->onKey;
|
||||
const auto keyHandler2 = menu->onKey->next;
|
||||
|
||||
ItemKeyHandler* qKeyHandler;
|
||||
ItemKeyHandler* leetKeyHandler;
|
||||
if (keyHandler1->key == 'q')
|
||||
{
|
||||
qKeyHandler = keyHandler1;
|
||||
leetKeyHandler = keyHandler2;
|
||||
}
|
||||
else
|
||||
{
|
||||
leetKeyHandler = keyHandler1;
|
||||
qKeyHandler = keyHandler2;
|
||||
}
|
||||
ItemKeyHandler* qKeyHandler;
|
||||
ItemKeyHandler* leetKeyHandler;
|
||||
if (keyHandler1->key == 'q')
|
||||
{
|
||||
qKeyHandler = keyHandler1;
|
||||
leetKeyHandler = keyHandler2;
|
||||
}
|
||||
else
|
||||
{
|
||||
leetKeyHandler = keyHandler1;
|
||||
qKeyHandler = keyHandler2;
|
||||
}
|
||||
|
||||
REQUIRE(qKeyHandler->key == 'q');
|
||||
REQUIRE(qKeyHandler->action->eventHandlerCount == 1);
|
||||
REQUIRE(qKeyHandler->action->eventHandlers != nullptr);
|
||||
REQUIRE(qKeyHandler->action->eventHandlers[0] != nullptr);
|
||||
REQUIRE(qKeyHandler->action->eventHandlers[0]->eventType == EVENT_UNCONDITIONAL);
|
||||
REQUIRE(qKeyHandler->action->eventHandlers[0]->eventData.unconditionalScript == R"("exec" "quit" ; )"s);
|
||||
REQUIRE(qKeyHandler->key == 'q');
|
||||
REQUIRE(qKeyHandler->action->eventHandlerCount == 1);
|
||||
REQUIRE(qKeyHandler->action->eventHandlers != nullptr);
|
||||
REQUIRE(qKeyHandler->action->eventHandlers[0] != nullptr);
|
||||
REQUIRE(qKeyHandler->action->eventHandlers[0]->eventType == EVENT_UNCONDITIONAL);
|
||||
REQUIRE(qKeyHandler->action->eventHandlers[0]->eventData.unconditionalScript == R"("exec" "quit" ; )"s);
|
||||
|
||||
REQUIRE(leetKeyHandler->key == 1337);
|
||||
REQUIRE(leetKeyHandler->action->eventHandlerCount == 1);
|
||||
REQUIRE(leetKeyHandler->action->eventHandlers != nullptr);
|
||||
REQUIRE(leetKeyHandler->action->eventHandlers[0] != nullptr);
|
||||
REQUIRE(leetKeyHandler->action->eventHandlers[0]->eventType == EVENT_UNCONDITIONAL);
|
||||
REQUIRE(leetKeyHandler->action->eventHandlers[0]->eventData.unconditionalScript == R"("exec" "vid_restart" ; )"s);
|
||||
REQUIRE(leetKeyHandler->key == 1337);
|
||||
REQUIRE(leetKeyHandler->action->eventHandlerCount == 1);
|
||||
REQUIRE(leetKeyHandler->action->eventHandlers != nullptr);
|
||||
REQUIRE(leetKeyHandler->action->eventHandlers[0] != nullptr);
|
||||
REQUIRE(leetKeyHandler->action->eventHandlers[0]->eventType == EVENT_UNCONDITIONAL);
|
||||
REQUIRE(leetKeyHandler->action->eventHandlers[0]->eventData.unconditionalScript == R"("exec" "vid_restart" ; )"s);
|
||||
|
||||
REQUIRE(menu->itemCount == 0);
|
||||
REQUIRE(menu->items == nullptr);
|
||||
}
|
||||
REQUIRE(menu->itemCount == 0);
|
||||
REQUIRE(menu->items == nullptr);
|
||||
}
|
||||
|
||||
TEST_CASE("MenuParsingIW4IT: Can specify event handler multiple times", "[parsing][converting][menu][it]")
|
||||
{
|
||||
MenuParsingItHelper helper;
|
||||
TEST_CASE("MenuParsingIW4IT: Can specify event handler multiple times", "[parsing][converting][menu][it]")
|
||||
{
|
||||
MenuParsingItHelper helper;
|
||||
|
||||
helper.AddFile(R"testmenu(
|
||||
helper.AddFile(R"testmenu(
|
||||
{
|
||||
menuDef
|
||||
{
|
||||
@@ -340,45 +342,44 @@ namespace test::game::iw4::menu::parsing::it
|
||||
}
|
||||
)testmenu");
|
||||
|
||||
const auto result = helper.RunIntegrationTest();
|
||||
REQUIRE(result);
|
||||
const auto result = helper.RunIntegrationTest();
|
||||
REQUIRE(result);
|
||||
|
||||
const auto* menuList = helper.GetMenuListAsset();
|
||||
const auto* menu = helper.GetMenuAsset("Blab");
|
||||
const auto* menuList = helper.GetMenuListAsset();
|
||||
const auto* menu = helper.GetMenuAsset("Blab");
|
||||
|
||||
REQUIRE(menuList->menuCount == 1);
|
||||
REQUIRE(menuList->menus);
|
||||
REQUIRE(menuList->menuCount == 1);
|
||||
REQUIRE(menuList->menus);
|
||||
|
||||
REQUIRE(menuList->menus[0] == menu);
|
||||
REQUIRE(menuList->menus[0] == menu);
|
||||
|
||||
REQUIRE(menu->window.name == "Blab"s);
|
||||
|
||||
REQUIRE(menu->onOpen != nullptr);
|
||||
REQUIRE(menu->onOpen->eventHandlerCount == 3);
|
||||
REQUIRE(menu->onOpen->eventHandlers[0]->eventType == EventType::EVENT_UNCONDITIONAL);
|
||||
REQUIRE(menu->onOpen->eventHandlers[0]->eventData.unconditionalScript != nullptr);
|
||||
REQUIRE(menu->onOpen->eventHandlers[0]->eventData.unconditionalScript == R"("focusFirst" ; )"s);
|
||||
REQUIRE(menu->onOpen->eventHandlers[1]->eventType == EventType::EVENT_UNCONDITIONAL);
|
||||
REQUIRE(menu->onOpen->eventHandlers[1]->eventData.unconditionalScript != nullptr);
|
||||
REQUIRE(menu->onOpen->eventHandlers[1]->eventData.unconditionalScript == R"("play" "fart_sound" ; )"s);
|
||||
REQUIRE(menu->onOpen->eventHandlers[2]->eventType == EventType::EVENT_UNCONDITIONAL);
|
||||
REQUIRE(menu->onOpen->eventHandlers[2]->eventData.unconditionalScript != nullptr);
|
||||
REQUIRE(menu->onOpen->eventHandlers[2]->eventData.unconditionalScript == R"("exec" "wait 1; set r_fullbright 1" ; )"s);
|
||||
|
||||
REQUIRE(menu->window.name == "Blab"s);
|
||||
|
||||
REQUIRE(menu->itemCount == 1);
|
||||
REQUIRE(menu->items != nullptr);
|
||||
REQUIRE(menu->onOpen != nullptr);
|
||||
REQUIRE(menu->onOpen->eventHandlerCount == 3);
|
||||
REQUIRE(menu->onOpen->eventHandlers[0]->eventType == EventType::EVENT_UNCONDITIONAL);
|
||||
REQUIRE(menu->onOpen->eventHandlers[0]->eventData.unconditionalScript != nullptr);
|
||||
REQUIRE(menu->onOpen->eventHandlers[0]->eventData.unconditionalScript == R"("focusFirst" ; )"s);
|
||||
REQUIRE(menu->onOpen->eventHandlers[1]->eventType == EventType::EVENT_UNCONDITIONAL);
|
||||
REQUIRE(menu->onOpen->eventHandlers[1]->eventData.unconditionalScript != nullptr);
|
||||
REQUIRE(menu->onOpen->eventHandlers[1]->eventData.unconditionalScript == R"("play" "fart_sound" ; )"s);
|
||||
REQUIRE(menu->onOpen->eventHandlers[2]->eventType == EventType::EVENT_UNCONDITIONAL);
|
||||
REQUIRE(menu->onOpen->eventHandlers[2]->eventData.unconditionalScript != nullptr);
|
||||
REQUIRE(menu->onOpen->eventHandlers[2]->eventData.unconditionalScript == R"("exec" "wait 1; set r_fullbright 1" ; )"s);
|
||||
|
||||
const auto* item = menu->items[0];
|
||||
REQUIRE(item != nullptr);
|
||||
REQUIRE(menu->itemCount == 1);
|
||||
REQUIRE(menu->items != nullptr);
|
||||
|
||||
REQUIRE(item->action != nullptr);
|
||||
REQUIRE(item->action->eventHandlerCount == 2);
|
||||
REQUIRE(item->action->eventHandlers[0]->eventType == EventType::EVENT_UNCONDITIONAL);
|
||||
REQUIRE(item->action->eventHandlers[0]->eventData.unconditionalScript != nullptr);
|
||||
REQUIRE(item->action->eventHandlers[0]->eventData.unconditionalScript == R"("play" "lmfao" ; )"s);
|
||||
REQUIRE(item->action->eventHandlers[1]->eventType == EventType::EVENT_UNCONDITIONAL);
|
||||
REQUIRE(item->action->eventHandlers[1]->eventData.unconditionalScript != nullptr);
|
||||
REQUIRE(item->action->eventHandlers[1]->eventData.unconditionalScript == R"("play" "lol" ; )"s);
|
||||
}
|
||||
}
|
||||
const auto* item = menu->items[0];
|
||||
REQUIRE(item != nullptr);
|
||||
|
||||
REQUIRE(item->action != nullptr);
|
||||
REQUIRE(item->action->eventHandlerCount == 2);
|
||||
REQUIRE(item->action->eventHandlers[0]->eventType == EventType::EVENT_UNCONDITIONAL);
|
||||
REQUIRE(item->action->eventHandlers[0]->eventData.unconditionalScript != nullptr);
|
||||
REQUIRE(item->action->eventHandlers[0]->eventData.unconditionalScript == R"("play" "lmfao" ; )"s);
|
||||
REQUIRE(item->action->eventHandlers[1]->eventType == EventType::EVENT_UNCONDITIONAL);
|
||||
REQUIRE(item->action->eventHandlers[1]->eventData.unconditionalScript != nullptr);
|
||||
REQUIRE(item->action->eventHandlers[1]->eventData.unconditionalScript == R"("play" "lol" ; )"s);
|
||||
}
|
||||
} // namespace test::game::iw4::menu::parsing::it
|
||||
|
||||
@@ -1,56 +1,59 @@
|
||||
#include "MockAssetLoadingManager.h"
|
||||
|
||||
MockAssetLoadingManager::MockAssetLoadingManager(Zone* zone, ISearchPath* searchPath)
|
||||
: m_zone(zone),
|
||||
m_mock_gdt(std::make_unique<Gdt>()),
|
||||
m_context(std::make_unique<AssetLoadingContext>(zone, searchPath, std::vector({m_mock_gdt.get()})))
|
||||
: m_zone(zone),
|
||||
m_mock_gdt(std::make_unique<Gdt>()),
|
||||
m_context(std::make_unique<AssetLoadingContext>(zone, searchPath, std::vector({m_mock_gdt.get()})))
|
||||
{
|
||||
}
|
||||
|
||||
AssetLoadingContext* MockAssetLoadingManager::GetAssetLoadingContext() const
|
||||
{
|
||||
return m_context.get();
|
||||
return m_context.get();
|
||||
}
|
||||
|
||||
XAssetInfoGeneric* MockAssetLoadingManager::AddAsset(const asset_type_t assetType, const std::string& assetName, void* asset, std::vector<XAssetInfoGeneric*> dependencies,
|
||||
XAssetInfoGeneric* MockAssetLoadingManager::AddAsset(const asset_type_t assetType,
|
||||
const std::string& assetName,
|
||||
void* asset,
|
||||
std::vector<XAssetInfoGeneric*> dependencies,
|
||||
std::vector<scr_string_t> usedScriptStrings)
|
||||
{
|
||||
XAssetInfoGeneric assetInfoObj{assetType, assetName, m_zone, std::move(dependencies), std::move(usedScriptStrings), asset};
|
||||
auto assetInfo = std::make_unique<XAssetInfoGeneric>(std::move(assetInfoObj));
|
||||
const auto assetInfoPtr = assetInfo.get();
|
||||
m_added_assets.emplace(std::make_pair(assetInfo->m_name, std::move(assetInfo)));
|
||||
XAssetInfoGeneric assetInfoObj{assetType, assetName, m_zone, std::move(dependencies), std::move(usedScriptStrings), asset};
|
||||
auto assetInfo = std::make_unique<XAssetInfoGeneric>(std::move(assetInfoObj));
|
||||
const auto assetInfoPtr = assetInfo.get();
|
||||
m_added_assets.emplace(std::make_pair(assetInfo->m_name, std::move(assetInfo)));
|
||||
|
||||
return assetInfoPtr;
|
||||
return assetInfoPtr;
|
||||
}
|
||||
|
||||
XAssetInfoGeneric* MockAssetLoadingManager::LoadDependency(const asset_type_t assetType, const std::string& assetName)
|
||||
{
|
||||
auto foundDependencies = m_available_dependencies.find(assetName);
|
||||
auto foundDependencies = m_available_dependencies.find(assetName);
|
||||
|
||||
while (foundDependencies != m_available_dependencies.end())
|
||||
{
|
||||
if (foundDependencies->second->m_type == assetType)
|
||||
return foundDependencies->second.get();
|
||||
while (foundDependencies != m_available_dependencies.end())
|
||||
{
|
||||
if (foundDependencies->second->m_type == assetType)
|
||||
return foundDependencies->second.get();
|
||||
|
||||
++foundDependencies;
|
||||
}
|
||||
++foundDependencies;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void MockAssetLoadingManager::MockAddAvailableDependency(const asset_type_t assetType, std::string assetName, void* asset)
|
||||
{
|
||||
XAssetInfoGeneric assetInfoObj{assetType, std::move(assetName), m_zone, std::vector<XAssetInfoGeneric*>(), std::vector<scr_string_t>(), asset};
|
||||
auto assetInfo = std::make_unique<XAssetInfoGeneric>(std::move(assetInfoObj));
|
||||
m_available_dependencies.emplace(std::make_pair(assetInfo->m_name, std::move(assetInfo)));
|
||||
XAssetInfoGeneric assetInfoObj{assetType, std::move(assetName), m_zone, std::vector<XAssetInfoGeneric*>(), std::vector<scr_string_t>(), asset};
|
||||
auto assetInfo = std::make_unique<XAssetInfoGeneric>(std::move(assetInfoObj));
|
||||
m_available_dependencies.emplace(std::make_pair(assetInfo->m_name, std::move(assetInfo)));
|
||||
}
|
||||
|
||||
XAssetInfoGeneric* MockAssetLoadingManager::MockGetAddedAsset(const std::string& assetName)
|
||||
{
|
||||
const auto foundAsset = m_added_assets.find(assetName);
|
||||
const auto foundAsset = m_added_assets.find(assetName);
|
||||
|
||||
if (foundAsset != m_added_assets.end())
|
||||
return foundAsset->second.get();
|
||||
if (foundAsset != m_added_assets.end())
|
||||
return foundAsset->second.get();
|
||||
|
||||
return nullptr;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -1,25 +1,29 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <map>
|
||||
|
||||
#include "AssetLoading/IAssetLoadingManager.h"
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
|
||||
class MockAssetLoadingManager final : public IAssetLoadingManager
|
||||
{
|
||||
Zone* m_zone;
|
||||
std::unique_ptr<Gdt> m_mock_gdt;
|
||||
std::unique_ptr<AssetLoadingContext> m_context;
|
||||
std::map<std::string, std::unique_ptr<XAssetInfoGeneric>> m_added_assets;
|
||||
std::multimap<std::string, std::unique_ptr<XAssetInfoGeneric>> m_available_dependencies;
|
||||
Zone* m_zone;
|
||||
std::unique_ptr<Gdt> m_mock_gdt;
|
||||
std::unique_ptr<AssetLoadingContext> m_context;
|
||||
std::map<std::string, std::unique_ptr<XAssetInfoGeneric>> m_added_assets;
|
||||
std::multimap<std::string, std::unique_ptr<XAssetInfoGeneric>> m_available_dependencies;
|
||||
|
||||
public:
|
||||
MockAssetLoadingManager(Zone* zone, ISearchPath* searchPath);
|
||||
MockAssetLoadingManager(Zone* zone, ISearchPath* searchPath);
|
||||
|
||||
_NODISCARD AssetLoadingContext* GetAssetLoadingContext() const override;
|
||||
XAssetInfoGeneric* AddAsset(asset_type_t assetType, const std::string& assetName, void* asset, std::vector<XAssetInfoGeneric*> dependencies, std::vector<scr_string_t> usedScriptStrings) override;
|
||||
XAssetInfoGeneric* LoadDependency(asset_type_t assetType, const std::string& assetName) override;
|
||||
_NODISCARD AssetLoadingContext* GetAssetLoadingContext() const override;
|
||||
XAssetInfoGeneric* AddAsset(asset_type_t assetType,
|
||||
const std::string& assetName,
|
||||
void* asset,
|
||||
std::vector<XAssetInfoGeneric*> dependencies,
|
||||
std::vector<scr_string_t> usedScriptStrings) override;
|
||||
XAssetInfoGeneric* LoadDependency(asset_type_t assetType, const std::string& assetName) override;
|
||||
|
||||
void MockAddAvailableDependency(asset_type_t assetType, std::string assetName, void* asset);
|
||||
XAssetInfoGeneric* MockGetAddedAsset(const std::string& assetName);
|
||||
void MockAddAvailableDependency(asset_type_t assetType, std::string assetName, void* asset);
|
||||
XAssetInfoGeneric* MockGetAddedAsset(const std::string& assetName);
|
||||
};
|
||||
|
||||
@@ -4,24 +4,22 @@
|
||||
|
||||
void MockSearchPath::AddFileData(std::string fileName, std::string fileData)
|
||||
{
|
||||
m_file_data_map.emplace(std::make_pair(std::move(fileName), std::move(fileData)));
|
||||
m_file_data_map.emplace(std::make_pair(std::move(fileName), std::move(fileData)));
|
||||
}
|
||||
|
||||
SearchPathOpenFile MockSearchPath::Open(const std::string& fileName)
|
||||
{
|
||||
const auto foundFileData = m_file_data_map.find(fileName);
|
||||
const auto foundFileData = m_file_data_map.find(fileName);
|
||||
|
||||
if(foundFileData == m_file_data_map.end())
|
||||
return {};
|
||||
if (foundFileData == m_file_data_map.end())
|
||||
return {};
|
||||
|
||||
return {std::make_unique<std::istringstream>(foundFileData->second), foundFileData->second.size()};
|
||||
return {std::make_unique<std::istringstream>(foundFileData->second), foundFileData->second.size()};
|
||||
}
|
||||
|
||||
std::string MockSearchPath::GetPath()
|
||||
{
|
||||
return "MockFiles";
|
||||
return "MockFiles";
|
||||
}
|
||||
|
||||
void MockSearchPath::Find(const SearchPathSearchOptions& options, const std::function<void(const std::string&)>& callback)
|
||||
{
|
||||
}
|
||||
void MockSearchPath::Find(const SearchPathSearchOptions& options, const std::function<void(const std::string&)>& callback) {}
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
#pragma once
|
||||
#include <map>
|
||||
|
||||
#include "SearchPath/ISearchPath.h"
|
||||
|
||||
#include <map>
|
||||
|
||||
class MockSearchPath final : public ISearchPath
|
||||
{
|
||||
std::map<std::string, std::string> m_file_data_map;
|
||||
std::map<std::string, std::string> m_file_data_map;
|
||||
|
||||
public:
|
||||
void AddFileData(std::string fileName, std::string fileData);
|
||||
void AddFileData(std::string fileName, std::string fileData);
|
||||
|
||||
SearchPathOpenFile Open(const std::string& fileName) override;
|
||||
std::string GetPath() override;
|
||||
void Find(const SearchPathSearchOptions& options, const std::function<void(const std::string&)>& callback) override;
|
||||
SearchPathOpenFile Open(const std::string& fileName) override;
|
||||
std::string GetPath() override;
|
||||
void Find(const SearchPathSearchOptions& options, const std::function<void(const std::string&)>& callback) override;
|
||||
};
|
||||
|
||||
+278
-416
File diff suppressed because it is too large
Load Diff
@@ -1,9 +1,9 @@
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
#include <catch2/generators/catch_generators.hpp>
|
||||
|
||||
#include "Utils/ClassUtils.h"
|
||||
#include "Parsing/Menu/Sequence/ItemScopeSequences.h"
|
||||
#include "Parsing/Mock/MockLexer.h"
|
||||
#include "Utils/ClassUtils.h"
|
||||
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
#include <catch2/generators/catch_generators.hpp>
|
||||
|
||||
using namespace menu;
|
||||
|
||||
@@ -61,25 +61,23 @@ namespace test::parsing::menu::sequence::item
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
TEST_CASE("ItemScopeSequences: Simple dvarStrList works", "[parsing][sequence][menu]")
|
||||
{
|
||||
ItemSequenceTestsHelper helper(FeatureLevel::IW4, false);
|
||||
const TokenPos pos;
|
||||
helper.Tokens({
|
||||
SimpleParserValue::Identifier(pos, new std::string("dvarStrList")),
|
||||
SimpleParserValue::Character(pos, '{'),
|
||||
SimpleParserValue::String(pos, new std::string("@MENU_AUTO")),
|
||||
SimpleParserValue::String(pos, new std::string("auto")),
|
||||
SimpleParserValue::String(pos, new std::string("@MENU_STANDARD_4_3")),
|
||||
SimpleParserValue::String(pos, new std::string("standard")),
|
||||
SimpleParserValue::String(pos, new std::string("@MENU_WIDE_16_10")),
|
||||
SimpleParserValue::String(pos, new std::string("wide 16:10")),
|
||||
SimpleParserValue::String(pos, new std::string("@MENU_WIDE_16_9")),
|
||||
SimpleParserValue::String(pos, new std::string("wide 16:9")),
|
||||
SimpleParserValue::Character(pos, '}'),
|
||||
SimpleParserValue::EndOfFile(pos)
|
||||
});
|
||||
helper.Tokens({SimpleParserValue::Identifier(pos, new std::string("dvarStrList")),
|
||||
SimpleParserValue::Character(pos, '{'),
|
||||
SimpleParserValue::String(pos, new std::string("@MENU_AUTO")),
|
||||
SimpleParserValue::String(pos, new std::string("auto")),
|
||||
SimpleParserValue::String(pos, new std::string("@MENU_STANDARD_4_3")),
|
||||
SimpleParserValue::String(pos, new std::string("standard")),
|
||||
SimpleParserValue::String(pos, new std::string("@MENU_WIDE_16_10")),
|
||||
SimpleParserValue::String(pos, new std::string("wide 16:10")),
|
||||
SimpleParserValue::String(pos, new std::string("@MENU_WIDE_16_9")),
|
||||
SimpleParserValue::String(pos, new std::string("wide 16:9")),
|
||||
SimpleParserValue::Character(pos, '}'),
|
||||
SimpleParserValue::EndOfFile(pos)});
|
||||
|
||||
helper.m_item->m_feature_type = CommonItemFeatureType::MULTI_VALUE;
|
||||
helper.m_item->m_multi_value_features = std::make_unique<CommonItemFeaturesMultiValue>();
|
||||
@@ -89,4 +87,4 @@ namespace test::parsing::menu::sequence::item
|
||||
REQUIRE(result);
|
||||
REQUIRE(helper.m_consumed_token_count == 11);
|
||||
}
|
||||
}
|
||||
} // namespace test::parsing::menu::sequence::item
|
||||
|
||||
Reference in New Issue
Block a user