Reformat code with clang format

This commit is contained in:
Clang Format
2023-11-19 15:28:38 +01:00
committed by Jan
parent 22e17272fd
commit 6b4f5d94a8
1099 changed files with 16763 additions and 18076 deletions

View File

@ -1,20 +1,19 @@
#include "Image/ImageFormat.h"
#include <catch2/catch_test_macros.hpp>
#include <catch2/generators/catch_generators.hpp>
#include <type_traits>
#include "Image/ImageFormat.h"
namespace image::image_format
{
TEST_CASE("ImageFormat: EnsureAllFormatsArrayIndicesAreIds", "[image]")
{
REQUIRE(static_cast<unsigned int>(ImageFormatId::MAX) == std::extent<decltype(ImageFormat::ALL_FORMATS)>::value);
TEST_CASE("ImageFormat: EnsureAllFormatsArrayIndicesAreIds", "[image]")
{
REQUIRE(static_cast<unsigned int>(ImageFormatId::MAX) == std::extent<decltype(ImageFormat::ALL_FORMATS)>::value);
for(unsigned i = 0; i < std::extent<decltype(ImageFormat::ALL_FORMATS)>::value; i++)
{
REQUIRE(ImageFormat::ALL_FORMATS[i] != nullptr);
REQUIRE(i == static_cast<unsigned>(ImageFormat::ALL_FORMATS[i]->GetId()));
}
}
}
for (unsigned i = 0; i < std::extent<decltype(ImageFormat::ALL_FORMATS)>::value; i++)
{
REQUIRE(ImageFormat::ALL_FORMATS[i] != nullptr);
REQUIRE(i == static_cast<unsigned>(ImageFormat::ALL_FORMATS[i]->GetId()));
}
}
} // namespace image::image_format

View File

@ -1,341 +1,340 @@
#include <catch2/catch_test_macros.hpp>
#include <catch2/generators/catch_generators.hpp>
#include <sstream>
#include "Obj/Gdt/Gdt.h"
#include "Obj/Gdt/GdtStream.h"
#include <catch2/catch_test_macros.hpp>
#include <catch2/generators/catch_generators.hpp>
#include <sstream>
namespace obj::gdt
{
TEST_CASE("Gdt: Ensure can parse simple gdt", "[gdt]")
{
std::string gdtString = "{\n"
"\t\"test_entry\" ( \"test.gdf\" )\n"
"\t{\n"
"\t\t\"testkey\" \"testvalue\"\n"
"\t\t\"test2key\" \"test2value\"\n"
"\t}\n"
"}";
std::istringstream ss(gdtString);
TEST_CASE("Gdt: Ensure can parse simple gdt", "[gdt]")
{
std::string gdtString = "{\n"
"\t\"test_entry\" ( \"test.gdf\" )\n"
"\t{\n"
"\t\t\"testkey\" \"testvalue\"\n"
"\t\t\"test2key\" \"test2value\"\n"
"\t}\n"
"}";
std::istringstream ss(gdtString);
Gdt gdt;
GdtReader reader(ss);
REQUIRE(reader.Read(gdt));
Gdt gdt;
GdtReader reader(ss);
REQUIRE(reader.Read(gdt));
REQUIRE(gdt.m_entries.size() == 1);
REQUIRE(gdt.m_entries.size() == 1);
{
const auto& entry = *gdt.m_entries[0];
REQUIRE(entry.m_name == "test_entry");
REQUIRE(entry.m_gdf_name == "test.gdf");
REQUIRE(entry.m_parent == nullptr);
REQUIRE(entry.m_properties.size() == 2);
{
const auto& entry = *gdt.m_entries[0];
REQUIRE(entry.m_name == "test_entry");
REQUIRE(entry.m_gdf_name == "test.gdf");
REQUIRE(entry.m_parent == nullptr);
REQUIRE(entry.m_properties.size() == 2);
REQUIRE(entry.m_properties.at("testkey") == "testvalue");
REQUIRE(entry.m_properties.at("test2key") == "test2value");
}
}
REQUIRE(entry.m_properties.at("testkey") == "testvalue");
REQUIRE(entry.m_properties.at("test2key") == "test2value");
}
}
TEST_CASE("Gdt: Ensure can parse compact gdt", "[gdt]")
{
std::string gdtString = "{"
R"("test_entry"("test.gdf"))"
"{"
R"("testkey""testvalue")"
R"("test2key""test2value")"
"}"
"}";
std::istringstream ss(gdtString);
TEST_CASE("Gdt: Ensure can parse compact gdt", "[gdt]")
{
std::string gdtString = "{"
R"("test_entry"("test.gdf"))"
"{"
R"("testkey""testvalue")"
R"("test2key""test2value")"
"}"
"}";
std::istringstream ss(gdtString);
Gdt gdt;
GdtReader reader(ss);
REQUIRE(reader.Read(gdt));
Gdt gdt;
GdtReader reader(ss);
REQUIRE(reader.Read(gdt));
REQUIRE(gdt.m_entries.size() == 1);
REQUIRE(gdt.m_entries.size() == 1);
{
const auto& entry = *gdt.m_entries[0];
REQUIRE(entry.m_name == "test_entry");
REQUIRE(entry.m_gdf_name == "test.gdf");
REQUIRE(entry.m_parent == nullptr);
REQUIRE(entry.m_properties.size() == 2);
{
const auto& entry = *gdt.m_entries[0];
REQUIRE(entry.m_name == "test_entry");
REQUIRE(entry.m_gdf_name == "test.gdf");
REQUIRE(entry.m_parent == nullptr);
REQUIRE(entry.m_properties.size() == 2);
REQUIRE(entry.m_properties.at("testkey") == "testvalue");
REQUIRE(entry.m_properties.at("test2key") == "test2value");
}
}
REQUIRE(entry.m_properties.at("testkey") == "testvalue");
REQUIRE(entry.m_properties.at("test2key") == "test2value");
}
}
TEST_CASE("Gdt: Ensure can parse version section", "[gdt]")
{
std::string gdtString = "{"
R"("version" ( "version.gdf" ))"
"{"
R"("game" "t6")"
R"("version" "1337")"
"}"
"}";
std::istringstream ss(gdtString);
TEST_CASE("Gdt: Ensure can parse version section", "[gdt]")
{
std::string gdtString = "{"
R"("version" ( "version.gdf" ))"
"{"
R"("game" "t6")"
R"("version" "1337")"
"}"
"}";
std::istringstream ss(gdtString);
Gdt gdt;
GdtReader reader(ss);
REQUIRE(reader.Read(gdt));
Gdt gdt;
GdtReader reader(ss);
REQUIRE(reader.Read(gdt));
REQUIRE(gdt.m_entries.empty());
REQUIRE(gdt.m_version.m_game == "t6");
REQUIRE(gdt.m_version.m_version == 1337);
}
REQUIRE(gdt.m_entries.empty());
REQUIRE(gdt.m_version.m_game == "t6");
REQUIRE(gdt.m_version.m_version == 1337);
}
TEST_CASE("Gdt: Ensure can parse version section and entries", "[gdt]")
{
std::string gdtString = "{"
R"("version" ( "version.gdf" ))"
"{"
R"("game" "t6")"
R"("version" "1337")"
"}"
R"("test_entry" ( "another_test.gdf" ))"
"{"
R"("game" "t6")"
R"("version" "420")"
"}"
"}";
std::istringstream ss(gdtString);
TEST_CASE("Gdt: Ensure can parse version section and entries", "[gdt]")
{
std::string gdtString = "{"
R"("version" ( "version.gdf" ))"
"{"
R"("game" "t6")"
R"("version" "1337")"
"}"
R"("test_entry" ( "another_test.gdf" ))"
"{"
R"("game" "t6")"
R"("version" "420")"
"}"
"}";
std::istringstream ss(gdtString);
Gdt gdt;
GdtReader reader(ss);
REQUIRE(reader.Read(gdt));
Gdt gdt;
GdtReader reader(ss);
REQUIRE(reader.Read(gdt));
REQUIRE(gdt.m_version.m_game == "t6");
REQUIRE(gdt.m_version.m_version == 1337);
REQUIRE(gdt.m_version.m_game == "t6");
REQUIRE(gdt.m_version.m_version == 1337);
REQUIRE(gdt.m_entries.size() == 1);
REQUIRE(gdt.m_entries.size() == 1);
{
const auto& entry = *gdt.m_entries[0];
REQUIRE(entry.m_name == "test_entry");
REQUIRE(entry.m_gdf_name == "another_test.gdf");
REQUIRE(entry.m_parent == nullptr);
REQUIRE(entry.m_properties.size() == 2);
{
const auto& entry = *gdt.m_entries[0];
REQUIRE(entry.m_name == "test_entry");
REQUIRE(entry.m_gdf_name == "another_test.gdf");
REQUIRE(entry.m_parent == nullptr);
REQUIRE(entry.m_properties.size() == 2);
REQUIRE(entry.m_properties.at("game") == "t6");
REQUIRE(entry.m_properties.at("version") == "420");
}
}
REQUIRE(entry.m_properties.at("game") == "t6");
REQUIRE(entry.m_properties.at("version") == "420");
}
}
TEST_CASE("Gdt: Ensure can parse multiple entries", "[gdt]")
{
std::string gdtString = "{"
R"("version" ( "version.gdf" ))"
"{"
R"("game" "t6")"
R"("version" "1337")"
"}"
R"("test_entry" ( "another_test.gdf" ))"
"{"
R"("game" "t6")"
R"("version" "420")"
"}"
R"("yet_another_entry" ( "super_kewl_asset_type.gdf" ))"
"{"
R"("name" "hello")"
R"("value" "asdf")"
R"("value2" "22")"
"}"
R"("final_entry" ( "quite_boring.gdf" ))"
"{"
R"("_HI_" "Hello World")"
"}"
"}";
std::istringstream ss(gdtString);
TEST_CASE("Gdt: Ensure can parse multiple entries", "[gdt]")
{
std::string gdtString = "{"
R"("version" ( "version.gdf" ))"
"{"
R"("game" "t6")"
R"("version" "1337")"
"}"
R"("test_entry" ( "another_test.gdf" ))"
"{"
R"("game" "t6")"
R"("version" "420")"
"}"
R"("yet_another_entry" ( "super_kewl_asset_type.gdf" ))"
"{"
R"("name" "hello")"
R"("value" "asdf")"
R"("value2" "22")"
"}"
R"("final_entry" ( "quite_boring.gdf" ))"
"{"
R"("_HI_" "Hello World")"
"}"
"}";
std::istringstream ss(gdtString);
Gdt gdt;
GdtReader reader(ss);
REQUIRE(reader.Read(gdt));
Gdt gdt;
GdtReader reader(ss);
REQUIRE(reader.Read(gdt));
REQUIRE(gdt.m_version.m_game == "t6");
REQUIRE(gdt.m_version.m_version == 1337);
REQUIRE(gdt.m_version.m_game == "t6");
REQUIRE(gdt.m_version.m_version == 1337);
REQUIRE(gdt.m_entries.size() == 3);
REQUIRE(gdt.m_entries.size() == 3);
{
const auto& entry = *gdt.m_entries[0];
REQUIRE(entry.m_name == "test_entry");
REQUIRE(entry.m_gdf_name == "another_test.gdf");
REQUIRE(entry.m_parent == nullptr);
REQUIRE(entry.m_properties.size() == 2);
{
const auto& entry = *gdt.m_entries[0];
REQUIRE(entry.m_name == "test_entry");
REQUIRE(entry.m_gdf_name == "another_test.gdf");
REQUIRE(entry.m_parent == nullptr);
REQUIRE(entry.m_properties.size() == 2);
REQUIRE(entry.m_properties.at("game") == "t6");
REQUIRE(entry.m_properties.at("version") == "420");
}
REQUIRE(entry.m_properties.at("game") == "t6");
REQUIRE(entry.m_properties.at("version") == "420");
}
{
const auto& entry = *gdt.m_entries[1];
REQUIRE(entry.m_name == "yet_another_entry");
REQUIRE(entry.m_gdf_name == "super_kewl_asset_type.gdf");
REQUIRE(entry.m_parent == nullptr);
REQUIRE(entry.m_properties.size() == 3);
{
const auto& entry = *gdt.m_entries[1];
REQUIRE(entry.m_name == "yet_another_entry");
REQUIRE(entry.m_gdf_name == "super_kewl_asset_type.gdf");
REQUIRE(entry.m_parent == nullptr);
REQUIRE(entry.m_properties.size() == 3);
REQUIRE(entry.m_properties.at("name") == "hello");
REQUIRE(entry.m_properties.at("value") == "asdf");
REQUIRE(entry.m_properties.at("value2") == "22");
}
REQUIRE(entry.m_properties.at("name") == "hello");
REQUIRE(entry.m_properties.at("value") == "asdf");
REQUIRE(entry.m_properties.at("value2") == "22");
}
{
const auto& entry = *gdt.m_entries[2];
REQUIRE(entry.m_name == "final_entry");
REQUIRE(entry.m_gdf_name == "quite_boring.gdf");
REQUIRE(entry.m_parent == nullptr);
REQUIRE(entry.m_properties.size() == 1);
{
const auto& entry = *gdt.m_entries[2];
REQUIRE(entry.m_name == "final_entry");
REQUIRE(entry.m_gdf_name == "quite_boring.gdf");
REQUIRE(entry.m_parent == nullptr);
REQUIRE(entry.m_properties.size() == 1);
REQUIRE(entry.m_properties.at("_HI_") == "Hello World");
}
}
REQUIRE(entry.m_properties.at("_HI_") == "Hello World");
}
}
TEST_CASE("Gdt: Ensure can parse entries with parent", "[gdt]")
{
std::string gdtString = "{"
R"("version" ( "version.gdf" ))"
"{"
R"("game" "t6")"
R"("version" "1337")"
"}"
R"("test_entry" ( "another_test.gdf" ))"
"{"
R"("game" "t6")"
R"("version" "420")"
"}"
R"("yet_another_entry" [ "test_entry" ])"
"{"
R"("name" "hello")"
R"("value" "asdf")"
R"("value2" "22")"
"}"
"}";
std::istringstream ss(gdtString);
TEST_CASE("Gdt: Ensure can parse entries with parent", "[gdt]")
{
std::string gdtString = "{"
R"("version" ( "version.gdf" ))"
"{"
R"("game" "t6")"
R"("version" "1337")"
"}"
R"("test_entry" ( "another_test.gdf" ))"
"{"
R"("game" "t6")"
R"("version" "420")"
"}"
R"("yet_another_entry" [ "test_entry" ])"
"{"
R"("name" "hello")"
R"("value" "asdf")"
R"("value2" "22")"
"}"
"}";
std::istringstream ss(gdtString);
Gdt gdt;
GdtReader reader(ss);
REQUIRE(reader.Read(gdt));
Gdt gdt;
GdtReader reader(ss);
REQUIRE(reader.Read(gdt));
REQUIRE(gdt.m_version.m_game == "t6");
REQUIRE(gdt.m_version.m_version == 1337);
REQUIRE(gdt.m_version.m_game == "t6");
REQUIRE(gdt.m_version.m_version == 1337);
REQUIRE(gdt.m_entries.size() == 2);
REQUIRE(gdt.m_entries.size() == 2);
{
const auto& entry = *gdt.m_entries[0];
REQUIRE(entry.m_name == "test_entry");
REQUIRE(entry.m_gdf_name == "another_test.gdf");
REQUIRE(entry.m_parent == nullptr);
REQUIRE(entry.m_properties.size() == 2);
{
const auto& entry = *gdt.m_entries[0];
REQUIRE(entry.m_name == "test_entry");
REQUIRE(entry.m_gdf_name == "another_test.gdf");
REQUIRE(entry.m_parent == nullptr);
REQUIRE(entry.m_properties.size() == 2);
REQUIRE(entry.m_properties.at("game") == "t6");
REQUIRE(entry.m_properties.at("version") == "420");
}
REQUIRE(entry.m_properties.at("game") == "t6");
REQUIRE(entry.m_properties.at("version") == "420");
}
{
const auto& entry = *gdt.m_entries[1];
REQUIRE(entry.m_name == "yet_another_entry");
REQUIRE(entry.m_parent == gdt.m_entries[0].get());
REQUIRE(entry.m_properties.size() == 3);
{
const auto& entry = *gdt.m_entries[1];
REQUIRE(entry.m_name == "yet_another_entry");
REQUIRE(entry.m_parent == gdt.m_entries[0].get());
REQUIRE(entry.m_properties.size() == 3);
REQUIRE(entry.m_properties.at("name") == "hello");
REQUIRE(entry.m_properties.at("value") == "asdf");
REQUIRE(entry.m_properties.at("value2") == "22");
}
}
REQUIRE(entry.m_properties.at("name") == "hello");
REQUIRE(entry.m_properties.at("value") == "asdf");
REQUIRE(entry.m_properties.at("value2") == "22");
}
}
TEST_CASE("Gdt: Ensure can write simple gdt and parse it again", "[gdt]")
{
Gdt gdt;
gdt.m_version.m_game = "whatagame";
gdt.m_version.m_version = 6969;
TEST_CASE("Gdt: Ensure can write simple gdt and parse it again", "[gdt]")
{
Gdt gdt;
gdt.m_version.m_game = "whatagame";
gdt.m_version.m_version = 6969;
{
auto entry = std::make_unique<GdtEntry>("sickentry", "verycool.gdf");
entry->m_properties["hello"] = "world";
entry->m_properties["hi"] = "universe";
gdt.m_entries.emplace_back(std::move(entry));
}
{
auto entry = std::make_unique<GdtEntry>("sickentry", "verycool.gdf");
entry->m_properties["hello"] = "world";
entry->m_properties["hi"] = "universe";
gdt.m_entries.emplace_back(std::move(entry));
}
{
auto entry = std::make_unique<GdtEntry>("evencoolerentry", gdt.m_entries[0].get());
entry->m_properties["nope"] = "xd";
entry->m_properties["idk"] = "whattotypeanymore";
gdt.m_entries.emplace_back(std::move(entry));
}
{
auto entry = std::make_unique<GdtEntry>("evencoolerentry", gdt.m_entries[0].get());
entry->m_properties["nope"] = "xd";
entry->m_properties["idk"] = "whattotypeanymore";
gdt.m_entries.emplace_back(std::move(entry));
}
std::stringstream ss;
GdtOutputStream::WriteGdt(gdt, ss);
std::stringstream ss;
GdtOutputStream::WriteGdt(gdt, ss);
std::cout << ss.str() << std::endl;
std::cout << ss.str() << std::endl;
Gdt gdt2;
GdtReader reader(ss);
REQUIRE(reader.Read(gdt2));
Gdt gdt2;
GdtReader reader(ss);
REQUIRE(reader.Read(gdt2));
REQUIRE(gdt2.m_version.m_game == "whatagame");
REQUIRE(gdt2.m_version.m_version == 6969);
REQUIRE(gdt2.m_version.m_game == "whatagame");
REQUIRE(gdt2.m_version.m_version == 6969);
REQUIRE(gdt2.m_entries.size() == 2);
REQUIRE(gdt2.m_entries.size() == 2);
{
const auto& entry = *gdt2.m_entries[0];
REQUIRE(entry.m_name == "sickentry");
REQUIRE(entry.m_gdf_name == "verycool.gdf");
REQUIRE(entry.m_parent == nullptr);
REQUIRE(entry.m_properties.size() == 2);
{
const auto& entry = *gdt2.m_entries[0];
REQUIRE(entry.m_name == "sickentry");
REQUIRE(entry.m_gdf_name == "verycool.gdf");
REQUIRE(entry.m_parent == nullptr);
REQUIRE(entry.m_properties.size() == 2);
REQUIRE(entry.m_properties.at("hello") == "world");
REQUIRE(entry.m_properties.at("hi") == "universe");
}
REQUIRE(entry.m_properties.at("hello") == "world");
REQUIRE(entry.m_properties.at("hi") == "universe");
}
{
const auto& entry = *gdt2.m_entries[1];
REQUIRE(entry.m_name == "evencoolerentry");
REQUIRE(entry.m_parent == gdt2.m_entries[0].get());
REQUIRE(entry.m_properties.size() == 2);
{
const auto& entry = *gdt2.m_entries[1];
REQUIRE(entry.m_name == "evencoolerentry");
REQUIRE(entry.m_parent == gdt2.m_entries[0].get());
REQUIRE(entry.m_properties.size() == 2);
REQUIRE(entry.m_properties.at("nope") == "xd");
REQUIRE(entry.m_properties.at("idk") == "whattotypeanymore");
}
}
REQUIRE(entry.m_properties.at("nope") == "xd");
REQUIRE(entry.m_properties.at("idk") == "whattotypeanymore");
}
}
TEST_CASE("Gdt: Ensure can write gdt with escape values and parse it again", "[gdt]")
{
Gdt gdt;
gdt.m_version.m_game = "whatagame";
gdt.m_version.m_version = 6969;
TEST_CASE("Gdt: Ensure can write gdt with escape values and parse it again", "[gdt]")
{
Gdt gdt;
gdt.m_version.m_game = "whatagame";
gdt.m_version.m_version = 6969;
{
auto entry = std::make_unique<GdtEntry>("sickentry", "verycool.gdf");
entry->m_properties["hello"] = "very\nkewl\\stuff";
gdt.m_entries.emplace_back(std::move(entry));
}
{
auto entry = std::make_unique<GdtEntry>("sickentry", "verycool.gdf");
entry->m_properties["hello"] = "very\nkewl\\stuff";
gdt.m_entries.emplace_back(std::move(entry));
}
std::stringstream ss;
GdtOutputStream::WriteGdt(gdt, ss);
std::stringstream ss;
GdtOutputStream::WriteGdt(gdt, ss);
std::cout << ss.str() << std::endl;
std::cout << ss.str() << std::endl;
Gdt gdt2;
GdtReader reader(ss);
REQUIRE(reader.Read(gdt2));
Gdt gdt2;
GdtReader reader(ss);
REQUIRE(reader.Read(gdt2));
REQUIRE(gdt2.m_version.m_game == "whatagame");
REQUIRE(gdt2.m_version.m_version == 6969);
REQUIRE(gdt2.m_version.m_game == "whatagame");
REQUIRE(gdt2.m_version.m_version == 6969);
REQUIRE(gdt2.m_entries.size() == 1);
REQUIRE(gdt2.m_entries.size() == 1);
{
const auto& entry = *gdt2.m_entries[0];
REQUIRE(entry.m_name == "sickentry");
REQUIRE(entry.m_gdf_name == "verycool.gdf");
REQUIRE(entry.m_parent == nullptr);
REQUIRE(entry.m_properties.size() == 1);
{
const auto& entry = *gdt2.m_entries[0];
REQUIRE(entry.m_name == "sickentry");
REQUIRE(entry.m_gdf_name == "verycool.gdf");
REQUIRE(entry.m_parent == nullptr);
REQUIRE(entry.m_properties.size() == 1);
REQUIRE(entry.m_properties.at("hello") == "very\nkewl\\stuff");
}
}
}
REQUIRE(entry.m_properties.at("hello") == "very\nkewl\\stuff");
}
}
} // namespace obj::gdt

View File

@ -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

View File

@ -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;
}

View File

@ -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);
};

View File

@ -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) {}

View File

@ -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;
};

View File

@ -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

View File

@ -1,13 +1,12 @@
#pragma once
#include <vector>
#include <iterator>
#include "Utils/ClassUtils.h"
#include "Parsing/ILexer.h"
#include "Utils/ClassUtils.h"
template <typename TokenType>
class MockLexer final : public ILexer<TokenType>
#include <iterator>
#include <vector>
template<typename TokenType> class MockLexer final : public ILexer<TokenType>
{
// TokenType must inherit IParserValue
static_assert(std::is_base_of<IParserValue, TokenType>::value);
@ -19,15 +18,15 @@ class MockLexer final : public ILexer<TokenType>
public:
MockLexer(std::initializer_list<Movable<TokenType>> tokens, TokenType eof)
: m_tokens(std::make_move_iterator(tokens.begin()), std::make_move_iterator(tokens.end())),
m_eof(std::move(eof)),
m_pop_count(0u)
m_eof(std::move(eof)),
m_pop_count(0u)
{
}
MockLexer(std::vector<TokenType> tokens, TokenType eof)
: m_tokens(std::move(tokens)),
m_eof(std::move(eof)),
m_pop_count(0u)
m_eof(std::move(eof)),
m_pop_count(0u)
{
}

View File

@ -1,7 +1,7 @@
#pragma once
#include "Utils/ClassUtils.h"
#include "Parsing/IPackValueSupplier.h"
#include "Utils/ClassUtils.h"
class MockPackValueSupplier final : public IPackValueSupplier
{

View File

@ -61,8 +61,10 @@ bool MockParserLineStream::IsOpen() const
bool MockParserLineStream::Eof() const
{
return !std::any_of(m_include_positions.begin(), m_include_positions.end(), [](const IncludePos& pos)
{
return pos.m_pos < pos.m_lines.size();
});
return !std::any_of(m_include_positions.begin(),
m_include_positions.end(),
[](const IncludePos& pos)
{
return pos.m_pos < pos.m_lines.size();
});
}

View File

@ -1,10 +1,10 @@
#pragma once
#include <vector>
#include <unordered_map>
#include "Parsing/IParserLineStream.h"
#include <unordered_map>
#include <vector>
class MockParserLineStream final : public IParserLineStream
{
public:
@ -20,7 +20,7 @@ private:
IncludePos(std::string filename, const std::vector<std::string>& lines);
};
std::unordered_map<std::string, std::vector<std::string>> m_include_lines;
std::vector<IncludePos> m_include_positions;

View File

@ -7,15 +7,14 @@ struct MockSequenceState
char m_dummy;
};
template<typename TokenType>
class MockSequence final : public AbstractSequence<TokenType, MockSequenceState>
template<typename TokenType> class MockSequence final : public AbstractSequence<TokenType, MockSequenceState>
{
public:
typedef AbstractSequence<TokenType, MockSequenceState> parent_t;
private:
using parent_t::AddMatchers;
using parent_t::AddLabeledMatchers;
using parent_t::AddMatchers;
std::function<void(SequenceResult<TokenType>&)> m_handler;
@ -46,4 +45,4 @@ public:
{
return this;
}
};
};

View File

@ -1,19 +1,14 @@
#include <catch2/catch_test_macros.hpp>
#include <catch2/generators/catch_generators.hpp>
#include "Parsing/Impl/CommentRemovingStreamProxy.h"
#include "Parsing/Mock/MockParserLineStream.h"
#include <catch2/catch_test_macros.hpp>
#include <catch2/generators/catch_generators.hpp>
namespace test::parsing::impl::comment_removing_stream_proxy
{
TEST_CASE("CommentRemovingStreamProxy: Ensure simple single line comment is working", "[parsing][parsingstream]")
{
const std::vector<std::string> lines
{
"// hello",
"prefix // test",
"t//est"
};
const std::vector<std::string> lines{"// hello", "prefix // test", "t//est"};
MockParserLineStream mockStream(lines);
CommentRemovingStreamProxy proxy(&mockStream);
@ -41,12 +36,7 @@ namespace test::parsing::impl::comment_removing_stream_proxy
TEST_CASE("CommentRemovingStreamProxy: Ensure single line comment expands to next line on backslash", "[parsing][parsingstream]")
{
const std::vector<std::string> lines
{
"// hello\\",
"this should still be a comment",
"this should not be a comment anymore"
};
const std::vector<std::string> lines{"// hello\\", "this should still be a comment", "this should not be a comment anymore"};
MockParserLineStream mockStream(lines);
CommentRemovingStreamProxy proxy(&mockStream);
@ -74,13 +64,7 @@ namespace test::parsing::impl::comment_removing_stream_proxy
TEST_CASE("CommentRemovingStreamProxy: Ensure single line comment expands to next line on backslash and is repeatable", "[parsing][parsingstream]")
{
const std::vector<std::string> lines
{
"// hello\\",
"this should still be a comment \\",
"this as well",
"this not anymore"
};
const std::vector<std::string> lines{"// hello\\", "this should still be a comment \\", "this as well", "this not anymore"};
MockParserLineStream mockStream(lines);
CommentRemovingStreamProxy proxy(&mockStream);
@ -114,12 +98,7 @@ namespace test::parsing::impl::comment_removing_stream_proxy
TEST_CASE("CommentRemovingStreamProxy: Ensure backslash must be last character to expand single line comment to next line", "[parsing][parsingstream]")
{
const std::vector<std::string> lines
{
"// hello\\",
"this should still be a comment \\ ",
"this not anymore"
};
const std::vector<std::string> lines{"// hello\\", "this should still be a comment \\ ", "this not anymore"};
MockParserLineStream mockStream(lines);
CommentRemovingStreamProxy proxy(&mockStream);
@ -147,13 +126,7 @@ namespace test::parsing::impl::comment_removing_stream_proxy
TEST_CASE("CommentRemovingStreamProxy: Ensure simple multiline comment works on one line", "[parsing][parsingstream]")
{
const std::vector<std::string> lines
{
"hello/* hell*/ world",
"/*this should be a comment*/",
"Hello /*asdf*/",
"/*asdf*/World"
};
const std::vector<std::string> lines{"hello/* hell*/ world", "/*this should be a comment*/", "Hello /*asdf*/", "/*asdf*/World"};
MockParserLineStream mockStream(lines);
CommentRemovingStreamProxy proxy(&mockStream);
@ -187,13 +160,7 @@ namespace test::parsing::impl::comment_removing_stream_proxy
TEST_CASE("CommentRemovingStreamProxy: Ensure simple multiline comment works over multiple lines", "[parsing][parsingstream]")
{
const std::vector<std::string> lines
{
"hello/* hell",
" hell*/ world/*nope",
"notatall",
"hehe*/xd"
};
const std::vector<std::string> lines{"hello/* hell", " hell*/ world/*nope", "notatall", "hehe*/xd"};
MockParserLineStream mockStream(lines);
CommentRemovingStreamProxy proxy(&mockStream);
@ -227,8 +194,7 @@ namespace test::parsing::impl::comment_removing_stream_proxy
TEST_CASE("CommentRemovingStreamProxy: Can have multiple comment blocks in one line", "[parsing][parsingstream]")
{
const std::vector<std::string> lines
{
const std::vector<std::string> lines{
"Hello/* lovely*/ world and/* beautiful*/ universe",
"Hello/* lovely*/ world// and beautiful universe",
};
@ -250,4 +216,4 @@ namespace test::parsing::impl::comment_removing_stream_proxy
REQUIRE(proxy.Eof());
}
}
} // namespace test::parsing::impl::comment_removing_stream_proxy

View File

@ -1,9 +1,9 @@
#include <catch2/catch_test_macros.hpp>
#include <catch2/generators/catch_generators.hpp>
#include "Parsing/Impl/DefinesStreamProxy.h"
#include "Parsing/Mock/MockParserLineStream.h"
#include <catch2/catch_test_macros.hpp>
#include <catch2/generators/catch_generators.hpp>
namespace test::parsing::impl::defines_stream_proxy
{
void ExpectLine(IParserLineStream* stream, const int lineNumber, const std::string& value)
@ -15,14 +15,7 @@ namespace test::parsing::impl::defines_stream_proxy
TEST_CASE("DefinesStreamProxy: Ensure simple define and positive ifdef is working", "[parsing][parsingstream]")
{
const std::vector<std::string> lines
{
"#define ASDF",
"#ifdef ASDF",
"Hello World",
"#endif",
"Hello Galaxy"
};
const std::vector<std::string> lines{"#define ASDF", "#ifdef ASDF", "Hello World", "#endif", "Hello Galaxy"};
MockParserLineStream mockStream(lines);
DefinesStreamProxy proxy(&mockStream);
@ -38,14 +31,7 @@ namespace test::parsing::impl::defines_stream_proxy
TEST_CASE("DefinesStreamProxy: Ensure simple define and negative ifdef is working", "[parsing][parsingstream]")
{
const std::vector<std::string> lines
{
"#define ASDF",
"#ifdef NONO",
"Hello World",
"#endif",
"Hello Galaxy"
};
const std::vector<std::string> lines{"#define ASDF", "#ifdef NONO", "Hello World", "#endif", "Hello Galaxy"};
MockParserLineStream mockStream(lines);
DefinesStreamProxy proxy(&mockStream);
@ -61,14 +47,7 @@ namespace test::parsing::impl::defines_stream_proxy
TEST_CASE("DefinesStreamProxy: Ensure simple define and positive ifndef is working", "[parsing][parsingstream]")
{
const std::vector<std::string> lines
{
"#define ASDF",
"#ifndef NONO",
"Hello World",
"#endif",
"Hello Galaxy"
};
const std::vector<std::string> lines{"#define ASDF", "#ifndef NONO", "Hello World", "#endif", "Hello Galaxy"};
MockParserLineStream mockStream(lines);
DefinesStreamProxy proxy(&mockStream);
@ -84,14 +63,7 @@ namespace test::parsing::impl::defines_stream_proxy
TEST_CASE("DefinesStreamProxy: Ensure simple define and negative ifndef is working", "[parsing][parsingstream]")
{
const std::vector<std::string> lines
{
"#define ASDF",
"#ifndef ASDF",
"Hello World",
"#endif",
"Hello Galaxy"
};
const std::vector<std::string> lines{"#define ASDF", "#ifndef ASDF", "Hello World", "#endif", "Hello Galaxy"};
MockParserLineStream mockStream(lines);
DefinesStreamProxy proxy(&mockStream);
@ -107,16 +79,7 @@ namespace test::parsing::impl::defines_stream_proxy
TEST_CASE("DefinesStreamProxy: Ensure else is working", "[parsing][parsingstream]")
{
const std::vector<std::string> lines
{
"#define ASDF",
"#ifdef NONO",
"Hello World1",
"#else",
"Hello World2",
"#endif",
"Hello Galaxy"
};
const std::vector<std::string> lines{"#define ASDF", "#ifdef NONO", "Hello World1", "#else", "Hello World2", "#endif", "Hello Galaxy"};
MockParserLineStream mockStream(lines);
DefinesStreamProxy proxy(&mockStream);
@ -134,24 +97,21 @@ namespace test::parsing::impl::defines_stream_proxy
TEST_CASE("DefinesStreamProxy: Ensure nested ifdef is working", "[parsing][parsingstream]")
{
const std::vector<std::string> lines
{
"#define ASDF",
"#ifdef ASDF",
"#ifdef NONO",
"Hello World1",
"#else",
"Hello World2",
"#endif",
"#else",
"#ifdef ASDF",
"Hello World3",
"#else",
"Hello World4",
"#endif",
"#endif",
"Hello Galaxy"
};
const std::vector<std::string> lines{"#define ASDF",
"#ifdef ASDF",
"#ifdef NONO",
"Hello World1",
"#else",
"Hello World2",
"#endif",
"#else",
"#ifdef ASDF",
"Hello World3",
"#else",
"Hello World4",
"#endif",
"#endif",
"Hello Galaxy"};
MockParserLineStream mockStream(lines);
DefinesStreamProxy proxy(&mockStream);
@ -177,18 +137,8 @@ namespace test::parsing::impl::defines_stream_proxy
TEST_CASE("DefinesStreamProxy: Ensure undef is working", "[parsing][parsingstream]")
{
const std::vector<std::string> lines
{
"#define ASDF",
"#ifdef ASDF",
"Hello World",
"#endif",
"#undef ASDF",
"#ifdef ASDF",
"Hello World",
"#endif",
"Hello Galaxy"
};
const std::vector<std::string> lines{
"#define ASDF", "#ifdef ASDF", "Hello World", "#endif", "#undef ASDF", "#ifdef ASDF", "Hello World", "#endif", "Hello Galaxy"};
MockParserLineStream mockStream(lines);
DefinesStreamProxy proxy(&mockStream);
@ -208,18 +158,8 @@ namespace test::parsing::impl::defines_stream_proxy
TEST_CASE("DefinesStreamProxy: Ensure undef does not undefine everything", "[parsing][parsingstream]")
{
const std::vector<std::string> lines
{
"#define ASDF",
"#ifdef ASDF",
"Hello World",
"#endif",
"#undef NONO",
"#ifdef ASDF",
"Hello World",
"#endif",
"Hello Galaxy"
};
const std::vector<std::string> lines{
"#define ASDF", "#ifdef ASDF", "Hello World", "#endif", "#undef NONO", "#ifdef ASDF", "Hello World", "#endif", "Hello Galaxy"};
MockParserLineStream mockStream(lines);
DefinesStreamProxy proxy(&mockStream);
@ -239,14 +179,7 @@ namespace test::parsing::impl::defines_stream_proxy
TEST_CASE("DefinesStreamProxy: Ensure simple defines are working", "[parsing][parsingstream]")
{
const std::vector<std::string> lines
{
"#define ASDF LOL",
"ASDF",
"A ASDF B",
"ASDF B",
"A ASDF"
};
const std::vector<std::string> lines{"#define ASDF LOL", "ASDF", "A ASDF B", "ASDF B", "A ASDF"};
MockParserLineStream mockStream(lines);
DefinesStreamProxy proxy(&mockStream);
@ -262,11 +195,7 @@ namespace test::parsing::impl::defines_stream_proxy
TEST_CASE("DefinesStreamProxy: Ensure defines can be surrounded by symbols", "[parsing][parsingstream]")
{
const std::vector<std::string> lines
{
"#define ASDF LOL",
"!ASDF%"
};
const std::vector<std::string> lines{"#define ASDF LOL", "!ASDF%"};
MockParserLineStream mockStream(lines);
DefinesStreamProxy proxy(&mockStream);
@ -279,12 +208,7 @@ namespace test::parsing::impl::defines_stream_proxy
TEST_CASE("DefinesStreamProxy: Ensure can use multiple defines in one line", "[parsing][parsingstream]")
{
const std::vector<std::string> lines
{
"#define A Hello",
"#define B world",
"A my dear B!"
};
const std::vector<std::string> lines{"#define A Hello", "#define B world", "A my dear B!"};
MockParserLineStream mockStream(lines);
DefinesStreamProxy proxy(&mockStream);
@ -298,13 +222,7 @@ namespace test::parsing::impl::defines_stream_proxy
TEST_CASE("DefinesStreamProxy: Ensure defines in disabled block are ignored", "[parsing][parsingstream]")
{
const std::vector<std::string> lines
{
"#ifdef LOLO",
"#define hello world",
"#endif",
"hello"
};
const std::vector<std::string> lines{"#ifdef LOLO", "#define hello world", "#endif", "hello"};
MockParserLineStream mockStream(lines);
DefinesStreamProxy proxy(&mockStream);
@ -319,14 +237,7 @@ namespace test::parsing::impl::defines_stream_proxy
TEST_CASE("DefinesStreamProxy: Ensure undefs in disabled block are ignored", "[parsing][parsingstream]")
{
const std::vector<std::string> lines
{
"#define hello world",
"#ifdef LOLO",
"#undef hello",
"#endif",
"hello"
};
const std::vector<std::string> lines{"#define hello world", "#ifdef LOLO", "#undef hello", "#endif", "hello"};
MockParserLineStream mockStream(lines);
DefinesStreamProxy proxy(&mockStream);
@ -342,11 +253,7 @@ namespace test::parsing::impl::defines_stream_proxy
TEST_CASE("DefinesStreamProxy: Ensure can define name with underscores and digits", "[parsing][parsingstream]")
{
const std::vector<std::string> lines
{
"#define __int16 short",
"unsigned __int16 value;"
};
const std::vector<std::string> lines{"#define __int16 short", "unsigned __int16 value;"};
MockParserLineStream mockStream(lines);
DefinesStreamProxy proxy(&mockStream);
@ -361,14 +268,10 @@ namespace test::parsing::impl::defines_stream_proxy
{
DefinesStreamProxy::Define define("helloworld", "hello universe");
std::vector<std::string> parameterNames({
"universe"
});
std::vector<std::string> parameterNames({"universe"});
define.IdentifyParameters(parameterNames);
std::vector<std::string> parameterValues({
"mr moneyman"
});
std::vector<std::string> parameterValues({"mr moneyman"});
REQUIRE(define.Render(parameterValues) == "hello mr moneyman");
}
@ -376,24 +279,16 @@ namespace test::parsing::impl::defines_stream_proxy
{
DefinesStreamProxy::Define define("helloworld", "alignas(x)");
std::vector<std::string> parameterNames({
"x"
});
std::vector<std::string> parameterNames({"x"});
define.IdentifyParameters(parameterNames);
std::vector<std::string> parameterValues({
"1337"
});
std::vector<std::string> parameterValues({"1337"});
REQUIRE(define.Render(parameterValues) == "alignas(1337)");
}
TEST_CASE("DefinesStreamProxy: Ensure can add define with parameters", "[parsing][parsingstream]")
{
const std::vector<std::string> lines
{
"#define test(x) alignas(x)",
"struct test(1337) test_struct"
};
const std::vector<std::string> lines{"#define test(x) alignas(x)", "struct test(1337) test_struct"};
MockParserLineStream mockStream(lines);
DefinesStreamProxy proxy(&mockStream);
@ -406,11 +301,7 @@ namespace test::parsing::impl::defines_stream_proxy
TEST_CASE("DefinesStreamProxy: Ensure can use parameter multiple times", "[parsing][parsingstream]")
{
const std::vector<std::string> lines
{
"#define test(x) x|x|x|x",
"struct test(1337) test_struct"
};
const std::vector<std::string> lines{"#define test(x) x|x|x|x", "struct test(1337) test_struct"};
MockParserLineStream mockStream(lines);
DefinesStreamProxy proxy(&mockStream);
@ -423,11 +314,7 @@ namespace test::parsing::impl::defines_stream_proxy
TEST_CASE("DefinesStreamProxy: Ensure can use parameterized define in between symbols", "[parsing][parsingstream]")
{
const std::vector<std::string> lines
{
"#define test(x) x|x|x|x",
"%test(5)%"
};
const std::vector<std::string> lines{"#define test(x) x|x|x|x", "%test(5)%"};
MockParserLineStream mockStream(lines);
DefinesStreamProxy proxy(&mockStream);
@ -440,11 +327,7 @@ namespace test::parsing::impl::defines_stream_proxy
TEST_CASE("DefinesStreamProxy: Ensure can define multiple parameters", "[parsing][parsingstream]")
{
const std::vector<std::string> lines
{
"#define test(a1, a2, a3) a1 + a2 = a3",
"make calc test(1, 2, 3);"
};
const std::vector<std::string> lines{"#define test(a1, a2, a3) a1 + a2 = a3", "make calc test(1, 2, 3);"};
MockParserLineStream mockStream(lines);
DefinesStreamProxy proxy(&mockStream);
@ -457,11 +340,7 @@ namespace test::parsing::impl::defines_stream_proxy
TEST_CASE("DefinesStreamProxy: Ensure can define multiple parameters without spacing", "[parsing][parsingstream]")
{
const std::vector<std::string> lines
{
"#define test(a1,a2,a3) a1+a2=a3",
"make calc test(1,2,3);"
};
const std::vector<std::string> lines{"#define test(a1,a2,a3) a1+a2=a3", "make calc test(1,2,3);"};
MockParserLineStream mockStream(lines);
DefinesStreamProxy proxy(&mockStream);
@ -474,11 +353,7 @@ namespace test::parsing::impl::defines_stream_proxy
TEST_CASE("DefinesStreamProxy: Ensure can define parameters with underscore", "[parsing][parsingstream]")
{
const std::vector<std::string> lines
{
"#define test(test_parameter) this is test_parameter",
"Apparently test(a very cool text);"
};
const std::vector<std::string> lines{"#define test(test_parameter) this is test_parameter", "Apparently test(a very cool text);"};
MockParserLineStream mockStream(lines);
DefinesStreamProxy proxy(&mockStream);
@ -491,8 +366,7 @@ namespace test::parsing::impl::defines_stream_proxy
TEST_CASE("DefinesStreamProxy: Ensure simple if is working with truthy value", "[parsing][parsingstream]")
{
const std::vector<std::string> lines
{
const std::vector<std::string> lines{
"#if 1",
"Hello World",
"#endif",
@ -510,8 +384,7 @@ namespace test::parsing::impl::defines_stream_proxy
TEST_CASE("DefinesStreamProxy: Ensure simple if is working with non-truthy value", "[parsing][parsingstream]")
{
const std::vector<std::string> lines
{
const std::vector<std::string> lines{
"#if 0",
"Hello World",
"#endif",
@ -529,8 +402,7 @@ namespace test::parsing::impl::defines_stream_proxy
TEST_CASE("DefinesStreamProxy: Ensure simple if is working with calculated values", "[parsing][parsingstream]")
{
const std::vector<std::string> lines
{
const std::vector<std::string> lines{
"#if 0 || 1",
"Hello World",
"#endif",
@ -554,8 +426,7 @@ namespace test::parsing::impl::defines_stream_proxy
TEST_CASE("DefinesStreamProxy: Ensure can handle defined operator with defined definition", "[parsing][parsingstream]")
{
const std::vector<std::string> lines
{
const std::vector<std::string> lines{
"#define someStuff 1",
"#if defined(someStuff)",
"Hello World",
@ -575,8 +446,7 @@ namespace test::parsing::impl::defines_stream_proxy
TEST_CASE("DefinesStreamProxy: Ensure can handle defined operator with undefined definition", "[parsing][parsingstream]")
{
const std::vector<std::string> lines
{
const std::vector<std::string> lines{
"#define someStuff 1",
"#if defined(someStuff) && defined(thisIsNotDefined)",
"Hello World",
@ -602,8 +472,7 @@ namespace test::parsing::impl::defines_stream_proxy
TEST_CASE("DefinesStreamProxy: Ensure can use elif", "[parsing][parsingstream]")
{
const std::vector<std::string> lines
{
const std::vector<std::string> lines{
"#define someStuff 1",
"#if defined(someStuff) && defined(thisIsNotDefined)",
"Hello World",
@ -637,8 +506,7 @@ namespace test::parsing::impl::defines_stream_proxy
TEST_CASE("DefinesStreamProxy: Ensure elif does not work when if was true", "[parsing][parsingstream]")
{
const std::vector<std::string> lines
{
const std::vector<std::string> lines{
"#define someStuff 1",
"#if defined(someStuff)",
"Hello World",
@ -662,8 +530,7 @@ namespace test::parsing::impl::defines_stream_proxy
TEST_CASE("DefinesStreamProxy: Ensure can use else when no elif matched", "[parsing][parsingstream]")
{
const std::vector<std::string> lines
{
const std::vector<std::string> lines{
"#define someStuff 1",
"#if 0",
"Hello World",
@ -691,11 +558,7 @@ namespace test::parsing::impl::defines_stream_proxy
TEST_CASE("DefinesStreamProxy: Ensure can use parenthesis in parameters values", "[parsing][parsingstream]")
{
const std::vector<std::string> lines
{
"#define someStuff(param1) Hello param1 World",
"someStuff(A sentence with (parenthesis) and stuff)"
};
const std::vector<std::string> lines{"#define someStuff(param1) Hello param1 World", "someStuff(A sentence with (parenthesis) and stuff)"};
MockParserLineStream mockStream(lines);
DefinesStreamProxy proxy(&mockStream);
@ -708,11 +571,8 @@ namespace test::parsing::impl::defines_stream_proxy
TEST_CASE("DefinesStreamProxy: Ensure can use comma in parenthesis in parameters values", "[parsing][parsingstream]")
{
const std::vector<std::string> lines
{
"#define someStuff(param1) Hello param1 World",
"someStuff(A sentence with (parenthesis and a , character) and stuff)"
};
const std::vector<std::string> lines{"#define someStuff(param1) Hello param1 World",
"someStuff(A sentence with (parenthesis and a , character) and stuff)"};
MockParserLineStream mockStream(lines);
DefinesStreamProxy proxy(&mockStream);
@ -725,12 +585,7 @@ namespace test::parsing::impl::defines_stream_proxy
TEST_CASE("DefinesStreamProxy: Ensure defines can go over multiple lines", "[parsing][parsingstream]")
{
const std::vector<std::string> lines
{
"#define someStuff(param1) Hello param1 World \\",
"and hello universe",
"someStuff(lovely)"
};
const std::vector<std::string> lines{"#define someStuff(param1) Hello param1 World \\", "and hello universe", "someStuff(lovely)"};
MockParserLineStream mockStream(lines);
DefinesStreamProxy proxy(&mockStream);
@ -741,4 +596,4 @@ namespace test::parsing::impl::defines_stream_proxy
REQUIRE(proxy.Eof());
}
}
} // namespace test::parsing::impl::defines_stream_proxy

View File

@ -1,24 +1,16 @@
#include <catch2/catch_test_macros.hpp>
#include <catch2/generators/catch_generators.hpp>
#include "Parsing/Impl/IncludingStreamProxy.h"
#include "Parsing/Mock/MockParserLineStream.h"
#include <catch2/catch_test_macros.hpp>
#include <catch2/generators/catch_generators.hpp>
namespace test::parsing::impl::including_stream_proxy
{
TEST_CASE("IncludingStreamProxy: Ensure simple include is working", "[parsing][parsingstream]")
{
const std::vector<std::string> lines
{
"Hello world",
"#include \"ASDF.txt\"",
"and bye"
};
const std::vector<std::string> lines{"Hello world", "#include \"ASDF.txt\"", "and bye"};
const std::vector<std::string> asdf
{
"Hello galaxy"
};
const std::vector<std::string> asdf{"Hello galaxy"};
MockParserLineStream mockStream(lines);
mockStream.AddIncludeLines("ASDF.txt", asdf);
@ -51,17 +43,9 @@ namespace test::parsing::impl::including_stream_proxy
TEST_CASE("IncludingStreamProxy: Ensure simple include with angle brackets is working", "[parsing][parsingstream]")
{
const std::vector<std::string> lines
{
"Hello world",
"#include <ASDF.txt>",
"and bye"
};
const std::vector<std::string> lines{"Hello world", "#include <ASDF.txt>", "and bye"};
const std::vector<std::string> asdf
{
"Hello galaxy"
};
const std::vector<std::string> asdf{"Hello galaxy"};
MockParserLineStream mockStream(lines);
mockStream.AddIncludeLines("ASDF.txt", asdf);
@ -94,17 +78,9 @@ namespace test::parsing::impl::including_stream_proxy
TEST_CASE("IncludingStreamProxy: Ensure can have spaces before include directive", "[parsing][parsingstream]")
{
const std::vector<std::string> lines
{
"Hello world",
" #include \"ASDF.txt\" ",
"and bye"
};
const std::vector<std::string> lines{"Hello world", " #include \"ASDF.txt\" ", "and bye"};
const std::vector<std::string> asdf
{
"Hello galaxy"
};
const std::vector<std::string> asdf{"Hello galaxy"};
MockParserLineStream mockStream(lines);
mockStream.AddIncludeLines("ASDF.txt", asdf);
@ -137,19 +113,9 @@ namespace test::parsing::impl::including_stream_proxy
TEST_CASE("IncludingStreamProxy: Ensure pragma once prevents including the same file more than once", "[parsing][parsingstream]")
{
const std::vector<std::string> lines
{
"Hello world",
"#include \"ASDF.txt\"",
"#include \"ASDF.txt\"",
"and bye"
};
const std::vector<std::string> lines{"Hello world", "#include \"ASDF.txt\"", "#include \"ASDF.txt\"", "and bye"};
const std::vector<std::string> asdf
{
"#pragma once",
"Hello galaxy"
};
const std::vector<std::string> asdf{"#pragma once", "Hello galaxy"};
MockParserLineStream mockStream(lines);
mockStream.AddIncludeLines("ASDF.txt", asdf);
@ -179,4 +145,4 @@ namespace test::parsing::impl::including_stream_proxy
REQUIRE(proxy.Eof());
}
}
} // namespace test::parsing::impl::including_stream_proxy

View File

@ -1,9 +1,9 @@
#include <catch2/catch_test_macros.hpp>
#include <catch2/generators/catch_generators.hpp>
#include "Parsing/Impl/PackDefinitionStreamProxy.h"
#include "Parsing/Mock/MockParserLineStream.h"
#include <catch2/catch_test_macros.hpp>
#include <catch2/generators/catch_generators.hpp>
namespace test::parsing::impl::pack_definition_stream_proxy
{
void ExpectLine(IParserLineStream* stream, const int lineNumber, const std::string& value)
@ -15,14 +15,7 @@ namespace test::parsing::impl::pack_definition_stream_proxy
TEST_CASE("PackDefinitionStreamProxy: Ensure simple pack directives are working", "[parsing][parsingstream]")
{
const std::vector<std::string> lines
{
"hello world",
"#pragma pack(push, 32)",
"hello galaxy",
"#pragma pack(pop)",
"hello universe"
};
const std::vector<std::string> lines{"hello world", "#pragma pack(push, 32)", "hello galaxy", "#pragma pack(pop)", "hello universe"};
MockParserLineStream mockStream(lines);
PackDefinitionStreamProxy proxy(&mockStream);
@ -37,4 +30,4 @@ namespace test::parsing::impl::pack_definition_stream_proxy
REQUIRE(proxy.Eof());
}
}
} // namespace test::parsing::impl::pack_definition_stream_proxy

View File

@ -1,16 +1,15 @@
#include <catch2/catch_test_macros.hpp>
#include <catch2/generators/catch_generators.hpp>
#include <sstream>
#include "Parsing/Impl/AbstractParser.h"
#include "Parsing/Impl/ParserSingleInputStream.h"
#include "Utils/ClassUtils.h"
#include "Parsing/Mock/MockLexer.h"
#include "Parsing/Simple/SimpleParserValue.h"
#include "Parsing/Simple/Expression/ISimpleExpression.h"
#include "Parsing/Simple/Expression/SimpleExpressionMatchers.h"
#include "Parsing/Simple/Matcher/SimpleMatcherFactory.h"
#include "Parsing/Simple/SimpleParserValue.h"
#include "Utils/ClassUtils.h"
#include <catch2/catch_test_macros.hpp>
#include <catch2/generators/catch_generators.hpp>
#include <sstream>
namespace test::parsing::simple::expression
{
@ -60,9 +59,7 @@ namespace test::parsing::simple::expression
protected:
const std::vector<sequence_t*>& GetTestsForState() override
{
static std::vector<sequence_t*> tests({
new SimpleExpressionSequence()
});
static std::vector<sequence_t*> tests({new SimpleExpressionSequence()});
return tests;
}
@ -143,12 +140,10 @@ namespace test::parsing::simple::expression
{
SimpleExpressionTestsHelper helper;
const TokenPos pos;
helper.Tokens({
SimpleParserValue::Integer(pos, 1336),
SimpleParserValue::Character(pos, '+'),
SimpleParserValue::Integer(pos, 1),
SimpleParserValue::EndOfFile(pos)
});
helper.Tokens({SimpleParserValue::Integer(pos, 1336),
SimpleParserValue::Character(pos, '+'),
SimpleParserValue::Integer(pos, 1),
SimpleParserValue::EndOfFile(pos)});
const auto result = helper.PerformTest();
@ -167,12 +162,10 @@ namespace test::parsing::simple::expression
{
SimpleExpressionTestsHelper helper;
const TokenPos pos;
helper.Tokens({
SimpleParserValue::Integer(pos, 428),
SimpleParserValue::Character(pos, '-'),
SimpleParserValue::Integer(pos, 8),
SimpleParserValue::EndOfFile(pos)
});
helper.Tokens({SimpleParserValue::Integer(pos, 428),
SimpleParserValue::Character(pos, '-'),
SimpleParserValue::Integer(pos, 8),
SimpleParserValue::EndOfFile(pos)});
const auto result = helper.PerformTest();
@ -191,12 +184,10 @@ namespace test::parsing::simple::expression
{
SimpleExpressionTestsHelper helper;
const TokenPos pos;
helper.Tokens({
SimpleParserValue::Integer(pos, 105),
SimpleParserValue::Character(pos, '*'),
SimpleParserValue::Integer(pos, 4),
SimpleParserValue::EndOfFile(pos)
});
helper.Tokens({SimpleParserValue::Integer(pos, 105),
SimpleParserValue::Character(pos, '*'),
SimpleParserValue::Integer(pos, 4),
SimpleParserValue::EndOfFile(pos)});
const auto result = helper.PerformTest();
@ -215,12 +206,10 @@ namespace test::parsing::simple::expression
{
SimpleExpressionTestsHelper helper;
const TokenPos pos;
helper.Tokens({
SimpleParserValue::Integer(pos, 561540),
SimpleParserValue::Character(pos, '/'),
SimpleParserValue::Integer(pos, 420),
SimpleParserValue::EndOfFile(pos)
});
helper.Tokens({SimpleParserValue::Integer(pos, 561540),
SimpleParserValue::Character(pos, '/'),
SimpleParserValue::Integer(pos, 420),
SimpleParserValue::EndOfFile(pos)});
const auto result = helper.PerformTest();
@ -239,12 +228,10 @@ namespace test::parsing::simple::expression
{
SimpleExpressionTestsHelper helper;
const TokenPos pos;
helper.Tokens({
SimpleParserValue::Integer(pos, 92673),
SimpleParserValue::Character(pos, '%'),
SimpleParserValue::Integer(pos, 1337),
SimpleParserValue::EndOfFile(pos)
});
helper.Tokens({SimpleParserValue::Integer(pos, 92673),
SimpleParserValue::Character(pos, '%'),
SimpleParserValue::Integer(pos, 1337),
SimpleParserValue::EndOfFile(pos)});
const auto result = helper.PerformTest();
@ -263,12 +250,10 @@ namespace test::parsing::simple::expression
{
SimpleExpressionTestsHelper helper;
const TokenPos pos;
helper.Tokens({
SimpleParserValue::Integer(pos, 0x7FFFFFF0),
SimpleParserValue::Character(pos, '&'),
SimpleParserValue::Integer(pos, 0x2AAAAAAA),
SimpleParserValue::EndOfFile(pos)
});
helper.Tokens({SimpleParserValue::Integer(pos, 0x7FFFFFF0),
SimpleParserValue::Character(pos, '&'),
SimpleParserValue::Integer(pos, 0x2AAAAAAA),
SimpleParserValue::EndOfFile(pos)});
const auto result = helper.PerformTest();
@ -287,12 +272,10 @@ namespace test::parsing::simple::expression
{
SimpleExpressionTestsHelper helper;
const TokenPos pos;
helper.Tokens({
SimpleParserValue::Integer(pos, 5),
SimpleParserValue::Character(pos, '|'),
SimpleParserValue::Integer(pos, 3),
SimpleParserValue::EndOfFile(pos)
});
helper.Tokens({SimpleParserValue::Integer(pos, 5),
SimpleParserValue::Character(pos, '|'),
SimpleParserValue::Integer(pos, 3),
SimpleParserValue::EndOfFile(pos)});
const auto result = helper.PerformTest();
@ -311,12 +294,11 @@ namespace test::parsing::simple::expression
{
SimpleExpressionTestsHelper helper;
const TokenPos pos;
helper.Tokens({
SimpleParserValue::Integer(pos, 105),
SimpleParserValue::MultiCharacter(pos, SimpleExpressionMatchers::MULTI_TOKEN_OFFSET_BINARY + static_cast<int>(SimpleBinaryOperationId::SHIFT_LEFT)),
SimpleParserValue::Integer(pos, 2),
SimpleParserValue::EndOfFile(pos)
});
helper.Tokens({SimpleParserValue::Integer(pos, 105),
SimpleParserValue::MultiCharacter(
pos, SimpleExpressionMatchers::MULTI_TOKEN_OFFSET_BINARY + static_cast<int>(SimpleBinaryOperationId::SHIFT_LEFT)),
SimpleParserValue::Integer(pos, 2),
SimpleParserValue::EndOfFile(pos)});
const auto result = helper.PerformTest();
@ -335,12 +317,11 @@ namespace test::parsing::simple::expression
{
SimpleExpressionTestsHelper helper;
const TokenPos pos;
helper.Tokens({
SimpleParserValue::Integer(pos, 42784),
SimpleParserValue::MultiCharacter(pos, SimpleExpressionMatchers::MULTI_TOKEN_OFFSET_BINARY + static_cast<int>(SimpleBinaryOperationId::SHIFT_RIGHT)),
SimpleParserValue::Integer(pos, 5),
SimpleParserValue::EndOfFile(pos)
});
helper.Tokens({SimpleParserValue::Integer(pos, 42784),
SimpleParserValue::MultiCharacter(
pos, SimpleExpressionMatchers::MULTI_TOKEN_OFFSET_BINARY + static_cast<int>(SimpleBinaryOperationId::SHIFT_RIGHT)),
SimpleParserValue::Integer(pos, 5),
SimpleParserValue::EndOfFile(pos)});
const auto result = helper.PerformTest();
@ -359,12 +340,10 @@ namespace test::parsing::simple::expression
{
SimpleExpressionTestsHelper helper;
const TokenPos pos;
helper.Tokens({
SimpleParserValue::Integer(pos, 1337),
SimpleParserValue::Character(pos, '>'),
SimpleParserValue::Integer(pos, 420),
SimpleParserValue::EndOfFile(pos)
});
helper.Tokens({SimpleParserValue::Integer(pos, 1337),
SimpleParserValue::Character(pos, '>'),
SimpleParserValue::Integer(pos, 420),
SimpleParserValue::EndOfFile(pos)});
const auto result = helper.PerformTest();
@ -383,12 +362,11 @@ namespace test::parsing::simple::expression
{
SimpleExpressionTestsHelper helper;
const TokenPos pos;
helper.Tokens({
SimpleParserValue::Integer(pos, 1337),
SimpleParserValue::MultiCharacter(pos, SimpleExpressionMatchers::MULTI_TOKEN_OFFSET_BINARY + static_cast<int>(SimpleBinaryOperationId::GREATER_EQUAL_THAN)),
SimpleParserValue::Integer(pos, 420),
SimpleParserValue::EndOfFile(pos)
});
helper.Tokens({SimpleParserValue::Integer(pos, 1337),
SimpleParserValue::MultiCharacter(
pos, SimpleExpressionMatchers::MULTI_TOKEN_OFFSET_BINARY + static_cast<int>(SimpleBinaryOperationId::GREATER_EQUAL_THAN)),
SimpleParserValue::Integer(pos, 420),
SimpleParserValue::EndOfFile(pos)});
const auto result = helper.PerformTest();
@ -407,12 +385,10 @@ namespace test::parsing::simple::expression
{
SimpleExpressionTestsHelper helper;
const TokenPos pos;
helper.Tokens({
SimpleParserValue::Integer(pos, 420),
SimpleParserValue::Character(pos, '<'),
SimpleParserValue::Integer(pos, 421),
SimpleParserValue::EndOfFile(pos)
});
helper.Tokens({SimpleParserValue::Integer(pos, 420),
SimpleParserValue::Character(pos, '<'),
SimpleParserValue::Integer(pos, 421),
SimpleParserValue::EndOfFile(pos)});
const auto result = helper.PerformTest();
@ -431,12 +407,11 @@ namespace test::parsing::simple::expression
{
SimpleExpressionTestsHelper helper;
const TokenPos pos;
helper.Tokens({
SimpleParserValue::Integer(pos, 420),
SimpleParserValue::MultiCharacter(pos, SimpleExpressionMatchers::MULTI_TOKEN_OFFSET_BINARY + static_cast<int>(SimpleBinaryOperationId::LESS_EQUAL_THAN)),
SimpleParserValue::Integer(pos, 421),
SimpleParserValue::EndOfFile(pos)
});
helper.Tokens({SimpleParserValue::Integer(pos, 420),
SimpleParserValue::MultiCharacter(
pos, SimpleExpressionMatchers::MULTI_TOKEN_OFFSET_BINARY + static_cast<int>(SimpleBinaryOperationId::LESS_EQUAL_THAN)),
SimpleParserValue::Integer(pos, 421),
SimpleParserValue::EndOfFile(pos)});
const auto result = helper.PerformTest();
@ -455,12 +430,11 @@ namespace test::parsing::simple::expression
{
SimpleExpressionTestsHelper helper;
const TokenPos pos;
helper.Tokens({
SimpleParserValue::Integer(pos, 1337),
SimpleParserValue::MultiCharacter(pos, SimpleExpressionMatchers::MULTI_TOKEN_OFFSET_BINARY + static_cast<int>(SimpleBinaryOperationId::EQUALS)),
SimpleParserValue::Integer(pos, 1337),
SimpleParserValue::EndOfFile(pos)
});
helper.Tokens(
{SimpleParserValue::Integer(pos, 1337),
SimpleParserValue::MultiCharacter(pos, SimpleExpressionMatchers::MULTI_TOKEN_OFFSET_BINARY + static_cast<int>(SimpleBinaryOperationId::EQUALS)),
SimpleParserValue::Integer(pos, 1337),
SimpleParserValue::EndOfFile(pos)});
const auto result = helper.PerformTest();
@ -479,12 +453,11 @@ namespace test::parsing::simple::expression
{
SimpleExpressionTestsHelper helper;
const TokenPos pos;
helper.Tokens({
SimpleParserValue::Integer(pos, 1337),
SimpleParserValue::MultiCharacter(pos, SimpleExpressionMatchers::MULTI_TOKEN_OFFSET_BINARY + static_cast<int>(SimpleBinaryOperationId::NOT_EQUAL)),
SimpleParserValue::Integer(pos, 1337),
SimpleParserValue::EndOfFile(pos)
});
helper.Tokens(
{SimpleParserValue::Integer(pos, 1337),
SimpleParserValue::MultiCharacter(pos, SimpleExpressionMatchers::MULTI_TOKEN_OFFSET_BINARY + static_cast<int>(SimpleBinaryOperationId::NOT_EQUAL)),
SimpleParserValue::Integer(pos, 1337),
SimpleParserValue::EndOfFile(pos)});
const auto result = helper.PerformTest();
@ -503,12 +476,11 @@ namespace test::parsing::simple::expression
{
SimpleExpressionTestsHelper helper;
const TokenPos pos;
helper.Tokens({
SimpleParserValue::Integer(pos, 1337),
SimpleParserValue::MultiCharacter(pos, SimpleExpressionMatchers::MULTI_TOKEN_OFFSET_BINARY + static_cast<int>(SimpleBinaryOperationId::AND)),
SimpleParserValue::Integer(pos, 420),
SimpleParserValue::EndOfFile(pos)
});
helper.Tokens(
{SimpleParserValue::Integer(pos, 1337),
SimpleParserValue::MultiCharacter(pos, SimpleExpressionMatchers::MULTI_TOKEN_OFFSET_BINARY + static_cast<int>(SimpleBinaryOperationId::AND)),
SimpleParserValue::Integer(pos, 420),
SimpleParserValue::EndOfFile(pos)});
const auto result = helper.PerformTest();
@ -527,12 +499,11 @@ namespace test::parsing::simple::expression
{
SimpleExpressionTestsHelper helper;
const TokenPos pos;
helper.Tokens({
SimpleParserValue::Integer(pos, 0),
SimpleParserValue::MultiCharacter(pos, SimpleExpressionMatchers::MULTI_TOKEN_OFFSET_BINARY + static_cast<int>(SimpleBinaryOperationId::OR)),
SimpleParserValue::Integer(pos, 1337),
SimpleParserValue::EndOfFile(pos)
});
helper.Tokens(
{SimpleParserValue::Integer(pos, 0),
SimpleParserValue::MultiCharacter(pos, SimpleExpressionMatchers::MULTI_TOKEN_OFFSET_BINARY + static_cast<int>(SimpleBinaryOperationId::OR)),
SimpleParserValue::Integer(pos, 1337),
SimpleParserValue::EndOfFile(pos)});
const auto result = helper.PerformTest();
@ -551,16 +522,14 @@ namespace test::parsing::simple::expression
{
SimpleExpressionTestsHelper helper;
const TokenPos pos;
helper.Tokens({
SimpleParserValue::Integer(pos, 100),
SimpleParserValue::Character(pos, '+'),
SimpleParserValue::Integer(pos, 4),
SimpleParserValue::Character(pos, '*'),
SimpleParserValue::Integer(pos, 25),
SimpleParserValue::Character(pos, '+'),
SimpleParserValue::Integer(pos, 220),
SimpleParserValue::EndOfFile(pos)
});
helper.Tokens({SimpleParserValue::Integer(pos, 100),
SimpleParserValue::Character(pos, '+'),
SimpleParserValue::Integer(pos, 4),
SimpleParserValue::Character(pos, '*'),
SimpleParserValue::Integer(pos, 25),
SimpleParserValue::Character(pos, '+'),
SimpleParserValue::Integer(pos, 220),
SimpleParserValue::EndOfFile(pos)});
const auto result = helper.PerformTest();
@ -579,16 +548,14 @@ namespace test::parsing::simple::expression
{
SimpleExpressionTestsHelper helper;
const TokenPos pos;
helper.Tokens({
SimpleParserValue::Character(pos, '('),
SimpleParserValue::Integer(pos, 40),
SimpleParserValue::Character(pos, '+'),
SimpleParserValue::Integer(pos, 2),
SimpleParserValue::Character(pos, ')'),
SimpleParserValue::Character(pos, '*'),
SimpleParserValue::Integer(pos, 10),
SimpleParserValue::EndOfFile(pos)
});
helper.Tokens({SimpleParserValue::Character(pos, '('),
SimpleParserValue::Integer(pos, 40),
SimpleParserValue::Character(pos, '+'),
SimpleParserValue::Integer(pos, 2),
SimpleParserValue::Character(pos, ')'),
SimpleParserValue::Character(pos, '*'),
SimpleParserValue::Integer(pos, 10),
SimpleParserValue::EndOfFile(pos)});
const auto result = helper.PerformTest();
@ -607,14 +574,12 @@ namespace test::parsing::simple::expression
{
SimpleExpressionTestsHelper helper;
const TokenPos pos;
helper.Tokens({
SimpleParserValue::Integer(pos, 1),
SimpleParserValue::Character(pos, '?'),
SimpleParserValue::Integer(pos, 420),
SimpleParserValue::Character(pos, ':'),
SimpleParserValue::Integer(pos, 1337),
SimpleParserValue::EndOfFile(pos)
});
helper.Tokens({SimpleParserValue::Integer(pos, 1),
SimpleParserValue::Character(pos, '?'),
SimpleParserValue::Integer(pos, 420),
SimpleParserValue::Character(pos, ':'),
SimpleParserValue::Integer(pos, 1337),
SimpleParserValue::EndOfFile(pos)});
const auto result = helper.PerformTest();
@ -633,14 +598,12 @@ namespace test::parsing::simple::expression
{
SimpleExpressionTestsHelper helper;
const TokenPos pos;
helper.Tokens({
SimpleParserValue::Integer(pos, 0),
SimpleParserValue::Character(pos, '?'),
SimpleParserValue::Integer(pos, 420),
SimpleParserValue::Character(pos, ':'),
SimpleParserValue::Integer(pos, 1337),
SimpleParserValue::EndOfFile(pos)
});
helper.Tokens({SimpleParserValue::Integer(pos, 0),
SimpleParserValue::Character(pos, '?'),
SimpleParserValue::Integer(pos, 420),
SimpleParserValue::Character(pos, ':'),
SimpleParserValue::Integer(pos, 1337),
SimpleParserValue::EndOfFile(pos)});
const auto result = helper.PerformTest();
@ -659,18 +622,16 @@ namespace test::parsing::simple::expression
{
SimpleExpressionTestsHelper helper;
const TokenPos pos;
helper.Tokens({
SimpleParserValue::Character(pos, '('),
SimpleParserValue::Integer(pos, 1),
SimpleParserValue::Character(pos, '?'),
SimpleParserValue::Integer(pos, 420),
SimpleParserValue::Character(pos, ':'),
SimpleParserValue::Integer(pos, 1337),
SimpleParserValue::Character(pos, ')'),
SimpleParserValue::Character(pos, '+'),
SimpleParserValue::Integer(pos, 1),
SimpleParserValue::EndOfFile(pos)
});
helper.Tokens({SimpleParserValue::Character(pos, '('),
SimpleParserValue::Integer(pos, 1),
SimpleParserValue::Character(pos, '?'),
SimpleParserValue::Integer(pos, 420),
SimpleParserValue::Character(pos, ':'),
SimpleParserValue::Integer(pos, 1337),
SimpleParserValue::Character(pos, ')'),
SimpleParserValue::Character(pos, '+'),
SimpleParserValue::Integer(pos, 1),
SimpleParserValue::EndOfFile(pos)});
const auto result = helper.PerformTest();
@ -689,18 +650,16 @@ namespace test::parsing::simple::expression
{
SimpleExpressionTestsHelper helper;
const TokenPos pos;
helper.Tokens({
SimpleParserValue::Character(pos, '('),
SimpleParserValue::Integer(pos, 0),
SimpleParserValue::Character(pos, '?'),
SimpleParserValue::Integer(pos, 420),
SimpleParserValue::Character(pos, ':'),
SimpleParserValue::Integer(pos, 1337),
SimpleParserValue::Character(pos, ')'),
SimpleParserValue::Character(pos, '+'),
SimpleParserValue::Integer(pos, 1),
SimpleParserValue::EndOfFile(pos)
});
helper.Tokens({SimpleParserValue::Character(pos, '('),
SimpleParserValue::Integer(pos, 0),
SimpleParserValue::Character(pos, '?'),
SimpleParserValue::Integer(pos, 420),
SimpleParserValue::Character(pos, ':'),
SimpleParserValue::Integer(pos, 1337),
SimpleParserValue::Character(pos, ')'),
SimpleParserValue::Character(pos, '+'),
SimpleParserValue::Integer(pos, 1),
SimpleParserValue::EndOfFile(pos)});
const auto result = helper.PerformTest();
@ -719,18 +678,16 @@ namespace test::parsing::simple::expression
{
SimpleExpressionTestsHelper helper;
const TokenPos pos;
helper.Tokens({
SimpleParserValue::Character(pos, '('),
SimpleParserValue::Integer(pos, -1),
SimpleParserValue::Character(pos, '+'),
SimpleParserValue::Integer(pos, 2),
SimpleParserValue::Character(pos, ')'),
SimpleParserValue::Character(pos, '?'),
SimpleParserValue::Integer(pos, 420),
SimpleParserValue::Character(pos, ':'),
SimpleParserValue::Integer(pos, 1337),
SimpleParserValue::EndOfFile(pos)
});
helper.Tokens({SimpleParserValue::Character(pos, '('),
SimpleParserValue::Integer(pos, -1),
SimpleParserValue::Character(pos, '+'),
SimpleParserValue::Integer(pos, 2),
SimpleParserValue::Character(pos, ')'),
SimpleParserValue::Character(pos, '?'),
SimpleParserValue::Integer(pos, 420),
SimpleParserValue::Character(pos, ':'),
SimpleParserValue::Integer(pos, 1337),
SimpleParserValue::EndOfFile(pos)});
const auto result = helper.PerformTest();
@ -749,18 +706,16 @@ namespace test::parsing::simple::expression
{
SimpleExpressionTestsHelper helper;
const TokenPos pos;
helper.Tokens({
SimpleParserValue::Integer(pos, 1),
SimpleParserValue::Character(pos, '?'),
SimpleParserValue::Character(pos, '('),
SimpleParserValue::Integer(pos, 210),
SimpleParserValue::Character(pos, '*'),
SimpleParserValue::Integer(pos, 2),
SimpleParserValue::Character(pos, ')'),
SimpleParserValue::Character(pos, ':'),
SimpleParserValue::Integer(pos, 1337),
SimpleParserValue::EndOfFile(pos)
});
helper.Tokens({SimpleParserValue::Integer(pos, 1),
SimpleParserValue::Character(pos, '?'),
SimpleParserValue::Character(pos, '('),
SimpleParserValue::Integer(pos, 210),
SimpleParserValue::Character(pos, '*'),
SimpleParserValue::Integer(pos, 2),
SimpleParserValue::Character(pos, ')'),
SimpleParserValue::Character(pos, ':'),
SimpleParserValue::Integer(pos, 1337),
SimpleParserValue::EndOfFile(pos)});
const auto result = helper.PerformTest();
@ -779,18 +734,16 @@ namespace test::parsing::simple::expression
{
SimpleExpressionTestsHelper helper;
const TokenPos pos;
helper.Tokens({
SimpleParserValue::Integer(pos, 0),
SimpleParserValue::Character(pos, '?'),
SimpleParserValue::Integer(pos, 420),
SimpleParserValue::Character(pos, ':'),
SimpleParserValue::Character(pos, '('),
SimpleParserValue::Integer(pos, 1336),
SimpleParserValue::Character(pos, '+'),
SimpleParserValue::Integer(pos, 1),
SimpleParserValue::Character(pos, ')'),
SimpleParserValue::EndOfFile(pos)
});
helper.Tokens({SimpleParserValue::Integer(pos, 0),
SimpleParserValue::Character(pos, '?'),
SimpleParserValue::Integer(pos, 420),
SimpleParserValue::Character(pos, ':'),
SimpleParserValue::Character(pos, '('),
SimpleParserValue::Integer(pos, 1336),
SimpleParserValue::Character(pos, '+'),
SimpleParserValue::Integer(pos, 1),
SimpleParserValue::Character(pos, ')'),
SimpleParserValue::EndOfFile(pos)});
const auto result = helper.PerformTest();
@ -840,5 +793,5 @@ namespace test::parsing::simple::expression
REQUIRE(value.m_type == SimpleExpressionValue::Type::INT);
REQUIRE(value.m_int_value == 11);
}
}
}
} // namespace it
} // namespace test::parsing::simple::expression

View File

@ -1,13 +1,10 @@
#include <catch2/catch_test_macros.hpp>
#include <catch2/generators/catch_generators.hpp>
#include "Parsing/Commands/Impl/CommandsLexer.h"
#include "Parsing/Mock/MockParserLineStream.h"
#include <catch2/catch_test_macros.hpp>
#include <catch2/generators/catch_generators.hpp>
namespace test::parsing::commands::impl::commands_lexer
{
TEST_CASE("CommandsLexer: ", "[parsing][commands]")
{
}
}
TEST_CASE("CommandsLexer: ", "[parsing][commands]") {}
} // namespace test::parsing::commands::impl::commands_lexer

View File

@ -1,12 +1,12 @@
#include <catch2/catch_test_macros.hpp>
#include <catch2/generators/catch_generators.hpp>
#include "Utils/ClassUtils.h"
#include "Parsing/Commands/Sequence/SequenceAction.h"
#include "Parsing/Mock/MockLexer.h"
#include "Parsing/PostProcessing/CreateMemberInformationPostProcessor.h"
#include "Parsing/PostProcessing/CreateStructureInformationPostProcessor.h"
#include "Persistence/InMemory/InMemoryRepository.h"
#include "Utils/ClassUtils.h"
#include <catch2/catch_test_macros.hpp>
#include <catch2/generators/catch_generators.hpp>
namespace test::parsing::commands::sequence::sequence_action
{
@ -54,8 +54,7 @@ namespace test::parsing::commands::sequence::sequence_action
auto createStructureInformation = std::make_unique<CreateStructureInformationPostProcessor>();
auto createMemberInformation = std::make_unique<CreateMemberInformationPostProcessor>();
return createStructureInformation->PostProcess(m_repository.get())
&& createMemberInformation->PostProcess(m_repository.get());
return createStructureInformation->PostProcess(m_repository.get()) && createMemberInformation->PostProcess(m_repository.get());
}
void AddSampleData()
@ -89,7 +88,6 @@ namespace test::parsing::commands::sequence::sequence_action
}
public:
CommandsSequenceTestsHelper()
: m_repository(std::make_unique<InMemoryRepository>()),
m_state(std::make_unique<CommandsParserState>(m_repository.get())),
@ -127,16 +125,14 @@ namespace test::parsing::commands::sequence::sequence_action
{
CommandsSequenceTestsHelper helper;
const TokenPos pos;
helper.Tokens({
CommandsParserValue::Identifier(pos, new std::string("set")),
CommandsParserValue::Identifier(pos, new std::string("action")),
CommandsParserValue::Identifier(pos, new std::string("test_struct_t")),
CommandsParserValue::Identifier(pos, new std::string("TestMethod")),
CommandsParserValue::Character(pos, '('),
CommandsParserValue::Character(pos, ')'),
CommandsParserValue::Character(pos, ';'),
CommandsParserValue::EndOfFile(pos)
});
helper.Tokens({CommandsParserValue::Identifier(pos, new std::string("set")),
CommandsParserValue::Identifier(pos, new std::string("action")),
CommandsParserValue::Identifier(pos, new std::string("test_struct_t")),
CommandsParserValue::Identifier(pos, new std::string("TestMethod")),
CommandsParserValue::Character(pos, '('),
CommandsParserValue::Character(pos, ')'),
CommandsParserValue::Character(pos, ';'),
CommandsParserValue::EndOfFile(pos)});
auto result = helper.PerformTest();
@ -151,17 +147,15 @@ namespace test::parsing::commands::sequence::sequence_action
{
CommandsSequenceTestsHelper helper;
const TokenPos pos;
helper.Tokens({
CommandsParserValue::Identifier(pos, new std::string("set")),
CommandsParserValue::Identifier(pos, new std::string("action")),
CommandsParserValue::Identifier(pos, new std::string("test_struct_t")),
CommandsParserValue::Identifier(pos, new std::string("TestMethod")),
CommandsParserValue::Character(pos, '('),
CommandsParserValue::Identifier(pos, new std::string("arg_t")),
CommandsParserValue::Character(pos, ')'),
CommandsParserValue::Character(pos, ';'),
CommandsParserValue::EndOfFile(pos)
});
helper.Tokens({CommandsParserValue::Identifier(pos, new std::string("set")),
CommandsParserValue::Identifier(pos, new std::string("action")),
CommandsParserValue::Identifier(pos, new std::string("test_struct_t")),
CommandsParserValue::Identifier(pos, new std::string("TestMethod")),
CommandsParserValue::Character(pos, '('),
CommandsParserValue::Identifier(pos, new std::string("arg_t")),
CommandsParserValue::Character(pos, ')'),
CommandsParserValue::Character(pos, ';'),
CommandsParserValue::EndOfFile(pos)});
auto result = helper.PerformTest();
@ -177,19 +171,17 @@ namespace test::parsing::commands::sequence::sequence_action
{
CommandsSequenceTestsHelper helper;
const TokenPos pos;
helper.Tokens({
CommandsParserValue::Identifier(pos, new std::string("set")),
CommandsParserValue::Identifier(pos, new std::string("action")),
CommandsParserValue::Identifier(pos, new std::string("test_struct_t")),
CommandsParserValue::Identifier(pos, new std::string("TestMethod")),
CommandsParserValue::Character(pos, '('),
CommandsParserValue::Identifier(pos, new std::string("arg_t")),
CommandsParserValue::Character(pos, ','),
CommandsParserValue::Identifier(pos, new std::string("another_arg_t")),
CommandsParserValue::Character(pos, ')'),
CommandsParserValue::Character(pos, ';'),
CommandsParserValue::EndOfFile(pos)
});
helper.Tokens({CommandsParserValue::Identifier(pos, new std::string("set")),
CommandsParserValue::Identifier(pos, new std::string("action")),
CommandsParserValue::Identifier(pos, new std::string("test_struct_t")),
CommandsParserValue::Identifier(pos, new std::string("TestMethod")),
CommandsParserValue::Character(pos, '('),
CommandsParserValue::Identifier(pos, new std::string("arg_t")),
CommandsParserValue::Character(pos, ','),
CommandsParserValue::Identifier(pos, new std::string("another_arg_t")),
CommandsParserValue::Character(pos, ')'),
CommandsParserValue::Character(pos, ';'),
CommandsParserValue::EndOfFile(pos)});
auto result = helper.PerformTest();
@ -206,21 +198,19 @@ namespace test::parsing::commands::sequence::sequence_action
{
CommandsSequenceTestsHelper helper;
const TokenPos pos;
helper.Tokens({
CommandsParserValue::Identifier(pos, new std::string("set")),
CommandsParserValue::Identifier(pos, new std::string("action")),
CommandsParserValue::Identifier(pos, new std::string("test_struct_t")),
CommandsParserValue::Identifier(pos, new std::string("TestMethod")),
CommandsParserValue::Character(pos, '('),
CommandsParserValue::Identifier(pos, new std::string("arg_t")),
CommandsParserValue::Character(pos, ','),
CommandsParserValue::Identifier(pos, new std::string("another_arg_t")),
CommandsParserValue::Character(pos, ','),
CommandsParserValue::Identifier(pos, new std::string("yeet_t")),
CommandsParserValue::Character(pos, ')'),
CommandsParserValue::Character(pos, ';'),
CommandsParserValue::EndOfFile(pos)
});
helper.Tokens({CommandsParserValue::Identifier(pos, new std::string("set")),
CommandsParserValue::Identifier(pos, new std::string("action")),
CommandsParserValue::Identifier(pos, new std::string("test_struct_t")),
CommandsParserValue::Identifier(pos, new std::string("TestMethod")),
CommandsParserValue::Character(pos, '('),
CommandsParserValue::Identifier(pos, new std::string("arg_t")),
CommandsParserValue::Character(pos, ','),
CommandsParserValue::Identifier(pos, new std::string("another_arg_t")),
CommandsParserValue::Character(pos, ','),
CommandsParserValue::Identifier(pos, new std::string("yeet_t")),
CommandsParserValue::Character(pos, ')'),
CommandsParserValue::Character(pos, ';'),
CommandsParserValue::EndOfFile(pos)});
auto result = helper.PerformTest();
@ -238,16 +228,14 @@ namespace test::parsing::commands::sequence::sequence_action
{
CommandsSequenceTestsHelper helper;
const TokenPos pos;
helper.Tokens({
CommandsParserValue::Identifier(pos, new std::string("set")),
CommandsParserValue::Identifier(pos, new std::string("action")),
CommandsParserValue::Identifier(pos, new std::string("unknown_struct_t")),
CommandsParserValue::Identifier(pos, new std::string("TestMethod")),
CommandsParserValue::Character(pos, '('),
CommandsParserValue::Character(pos, ')'),
CommandsParserValue::Character(pos, ';'),
CommandsParserValue::EndOfFile(pos)
});
helper.Tokens({CommandsParserValue::Identifier(pos, new std::string("set")),
CommandsParserValue::Identifier(pos, new std::string("action")),
CommandsParserValue::Identifier(pos, new std::string("unknown_struct_t")),
CommandsParserValue::Identifier(pos, new std::string("TestMethod")),
CommandsParserValue::Character(pos, '('),
CommandsParserValue::Character(pos, ')'),
CommandsParserValue::Character(pos, ';'),
CommandsParserValue::EndOfFile(pos)});
REQUIRE_THROWS_AS(helper.PerformTest(), ParsingException);
REQUIRE(helper.m_test_struct->m_post_load_action == nullptr);
@ -257,21 +245,19 @@ namespace test::parsing::commands::sequence::sequence_action
{
CommandsSequenceTestsHelper helper;
const TokenPos pos;
helper.Tokens({
CommandsParserValue::Identifier(pos, new std::string("set")),
CommandsParserValue::Identifier(pos, new std::string("action")),
CommandsParserValue::Identifier(pos, new std::string("test_struct_t")),
CommandsParserValue::Identifier(pos, new std::string("TestMethod")),
CommandsParserValue::Character(pos, '('),
CommandsParserValue::Identifier(pos, new std::string("arg_t")),
CommandsParserValue::Character(pos, ','),
CommandsParserValue::Identifier(pos, new std::string("another_arg_t")),
CommandsParserValue::Character(pos, ','),
CommandsParserValue::Identifier(pos, new std::string("unknown_type_t")),
CommandsParserValue::Character(pos, ')'),
CommandsParserValue::Character(pos, ';'),
CommandsParserValue::EndOfFile(pos)
});
helper.Tokens({CommandsParserValue::Identifier(pos, new std::string("set")),
CommandsParserValue::Identifier(pos, new std::string("action")),
CommandsParserValue::Identifier(pos, new std::string("test_struct_t")),
CommandsParserValue::Identifier(pos, new std::string("TestMethod")),
CommandsParserValue::Character(pos, '('),
CommandsParserValue::Identifier(pos, new std::string("arg_t")),
CommandsParserValue::Character(pos, ','),
CommandsParserValue::Identifier(pos, new std::string("another_arg_t")),
CommandsParserValue::Character(pos, ','),
CommandsParserValue::Identifier(pos, new std::string("unknown_type_t")),
CommandsParserValue::Character(pos, ')'),
CommandsParserValue::Character(pos, ';'),
CommandsParserValue::EndOfFile(pos)});
REQUIRE_THROWS_AS(helper.PerformTest(), ParsingException);
REQUIRE(helper.m_test_struct->m_post_load_action == nullptr);
@ -281,15 +267,13 @@ namespace test::parsing::commands::sequence::sequence_action
{
CommandsSequenceTestsHelper helper;
const TokenPos pos;
helper.Tokens({
CommandsParserValue::Identifier(pos, new std::string("set")),
CommandsParserValue::Identifier(pos, new std::string("action")),
CommandsParserValue::Identifier(pos, new std::string("TestMethod")),
CommandsParserValue::Character(pos, '('),
CommandsParserValue::Character(pos, ')'),
CommandsParserValue::Character(pos, ';'),
CommandsParserValue::EndOfFile(pos)
});
helper.Tokens({CommandsParserValue::Identifier(pos, new std::string("set")),
CommandsParserValue::Identifier(pos, new std::string("action")),
CommandsParserValue::Identifier(pos, new std::string("TestMethod")),
CommandsParserValue::Character(pos, '('),
CommandsParserValue::Character(pos, ')'),
CommandsParserValue::Character(pos, ';'),
CommandsParserValue::EndOfFile(pos)});
REQUIRE_THROWS_AS(helper.PerformTest(), ParsingException);
REQUIRE(helper.m_test_struct->m_post_load_action == nullptr);
@ -299,15 +283,13 @@ namespace test::parsing::commands::sequence::sequence_action
{
CommandsSequenceTestsHelper helper;
const TokenPos pos;
helper.Tokens({
CommandsParserValue::Identifier(pos, new std::string("set")),
CommandsParserValue::Identifier(pos, new std::string("action")),
CommandsParserValue::Identifier(pos, new std::string("TestMethod")),
CommandsParserValue::Character(pos, '('),
CommandsParserValue::Character(pos, ')'),
CommandsParserValue::Character(pos, ';'),
CommandsParserValue::EndOfFile(pos)
});
helper.Tokens({CommandsParserValue::Identifier(pos, new std::string("set")),
CommandsParserValue::Identifier(pos, new std::string("action")),
CommandsParserValue::Identifier(pos, new std::string("TestMethod")),
CommandsParserValue::Character(pos, '('),
CommandsParserValue::Character(pos, ')'),
CommandsParserValue::Character(pos, ';'),
CommandsParserValue::EndOfFile(pos)});
helper.m_state->SetInUse(helper.m_test_struct);
auto result = helper.PerformTest();
@ -323,19 +305,17 @@ namespace test::parsing::commands::sequence::sequence_action
{
CommandsSequenceTestsHelper helper;
const TokenPos pos;
helper.Tokens({
CommandsParserValue::Identifier(pos, new std::string("set")),
CommandsParserValue::Identifier(pos, new std::string("action")),
CommandsParserValue::Identifier(pos, new std::string("container_struct_t")),
CommandsParserValue::Character(pos, ':'),
CommandsParserValue::Character(pos, ':'),
CommandsParserValue::Identifier(pos, new std::string("m_child")),
CommandsParserValue::Identifier(pos, new std::string("TestMethod")),
CommandsParserValue::Character(pos, '('),
CommandsParserValue::Character(pos, ')'),
CommandsParserValue::Character(pos, ';'),
CommandsParserValue::EndOfFile(pos)
});
helper.Tokens({CommandsParserValue::Identifier(pos, new std::string("set")),
CommandsParserValue::Identifier(pos, new std::string("action")),
CommandsParserValue::Identifier(pos, new std::string("container_struct_t")),
CommandsParserValue::Character(pos, ':'),
CommandsParserValue::Character(pos, ':'),
CommandsParserValue::Identifier(pos, new std::string("m_child")),
CommandsParserValue::Identifier(pos, new std::string("TestMethod")),
CommandsParserValue::Character(pos, '('),
CommandsParserValue::Character(pos, ')'),
CommandsParserValue::Character(pos, ';'),
CommandsParserValue::EndOfFile(pos)});
auto result = helper.PerformTest();
@ -350,16 +330,14 @@ namespace test::parsing::commands::sequence::sequence_action
{
CommandsSequenceTestsHelper helper;
const TokenPos pos;
helper.Tokens({
CommandsParserValue::Identifier(pos, new std::string("set")),
CommandsParserValue::Identifier(pos, new std::string("action")),
CommandsParserValue::Identifier(pos, new std::string("m_child")),
CommandsParserValue::Identifier(pos, new std::string("TestMethod")),
CommandsParserValue::Character(pos, '('),
CommandsParserValue::Character(pos, ')'),
CommandsParserValue::Character(pos, ';'),
CommandsParserValue::EndOfFile(pos)
});
helper.Tokens({CommandsParserValue::Identifier(pos, new std::string("set")),
CommandsParserValue::Identifier(pos, new std::string("action")),
CommandsParserValue::Identifier(pos, new std::string("m_child")),
CommandsParserValue::Identifier(pos, new std::string("TestMethod")),
CommandsParserValue::Character(pos, '('),
CommandsParserValue::Character(pos, ')'),
CommandsParserValue::Character(pos, ';'),
CommandsParserValue::EndOfFile(pos)});
helper.m_state->SetInUse(helper.m_test_struct2);
auto result = helper.PerformTest();
@ -375,19 +353,17 @@ namespace test::parsing::commands::sequence::sequence_action
{
CommandsSequenceTestsHelper helper;
const TokenPos pos;
helper.Tokens({
CommandsParserValue::Identifier(pos, new std::string("set")),
CommandsParserValue::Identifier(pos, new std::string("action")),
CommandsParserValue::Identifier(pos, new std::string("container_struct_t")),
CommandsParserValue::Character(pos, ':'),
CommandsParserValue::Character(pos, ':'),
CommandsParserValue::Identifier(pos, new std::string("m_child")),
CommandsParserValue::Identifier(pos, new std::string("TestMethod")),
CommandsParserValue::Character(pos, '('),
CommandsParserValue::Character(pos, ')'),
CommandsParserValue::Character(pos, ';'),
CommandsParserValue::EndOfFile(pos)
});
helper.Tokens({CommandsParserValue::Identifier(pos, new std::string("set")),
CommandsParserValue::Identifier(pos, new std::string("action")),
CommandsParserValue::Identifier(pos, new std::string("container_struct_t")),
CommandsParserValue::Character(pos, ':'),
CommandsParserValue::Character(pos, ':'),
CommandsParserValue::Identifier(pos, new std::string("m_child")),
CommandsParserValue::Identifier(pos, new std::string("TestMethod")),
CommandsParserValue::Character(pos, '('),
CommandsParserValue::Character(pos, ')'),
CommandsParserValue::Character(pos, ';'),
CommandsParserValue::EndOfFile(pos)});
helper.m_state->SetInUse(helper.m_arg_struct2);
auto result = helper.PerformTest();
@ -403,21 +379,19 @@ namespace test::parsing::commands::sequence::sequence_action
{
CommandsSequenceTestsHelper helper;
const TokenPos pos;
helper.Tokens({
CommandsParserValue::Identifier(pos, new std::string("set")),
CommandsParserValue::Identifier(pos, new std::string("action")),
CommandsParserValue::Identifier(pos, new std::string("test_struct_t")),
CommandsParserValue::Character(pos, ':'),
CommandsParserValue::Character(pos, ':'),
CommandsParserValue::Identifier(pos, new std::string("m_test")),
CommandsParserValue::Identifier(pos, new std::string("TestMethod")),
CommandsParserValue::Character(pos, '('),
CommandsParserValue::Character(pos, ')'),
CommandsParserValue::Character(pos, ';'),
CommandsParserValue::EndOfFile(pos)
});
helper.Tokens({CommandsParserValue::Identifier(pos, new std::string("set")),
CommandsParserValue::Identifier(pos, new std::string("action")),
CommandsParserValue::Identifier(pos, new std::string("test_struct_t")),
CommandsParserValue::Character(pos, ':'),
CommandsParserValue::Character(pos, ':'),
CommandsParserValue::Identifier(pos, new std::string("m_test")),
CommandsParserValue::Identifier(pos, new std::string("TestMethod")),
CommandsParserValue::Character(pos, '('),
CommandsParserValue::Character(pos, ')'),
CommandsParserValue::Character(pos, ';'),
CommandsParserValue::EndOfFile(pos)});
REQUIRE_THROWS_AS(helper.PerformTest(), ParsingException);
REQUIRE(helper.m_test_struct->m_post_load_action == nullptr);
}
}
} // namespace test::parsing::commands::sequence::sequence_action

View File

@ -1,10 +1,10 @@
#include <catch2/catch_test_macros.hpp>
#include <catch2/generators/catch_generators.hpp>
#include "Utils/ClassUtils.h"
#include "Parsing/Commands/Sequence/SequenceArchitecture.h"
#include "Parsing/Mock/MockLexer.h"
#include "Persistence/InMemory/InMemoryRepository.h"
#include "Utils/ClassUtils.h"
#include <catch2/catch_test_macros.hpp>
#include <catch2/generators/catch_generators.hpp>
namespace test::parsing::commands::sequence::sequence_architecture
{
@ -16,7 +16,7 @@ namespace test::parsing::commands::sequence::sequence_architecture
std::unique_ptr<ILexer<CommandsParserValue>> m_lexer;
unsigned m_consumed_token_count;
CommandsSequenceTestsHelper()
: m_repository(std::make_unique<InMemoryRepository>()),
m_state(std::make_unique<CommandsParserState>(m_repository.get())),
@ -41,12 +41,10 @@ namespace test::parsing::commands::sequence::sequence_architecture
{
CommandsSequenceTestsHelper helper;
const TokenPos pos;
helper.Tokens({
CommandsParserValue::Identifier(pos, new std::string("architecture")),
CommandsParserValue::Identifier(pos, new std::string("x86")),
CommandsParserValue::Character(pos, ';'),
CommandsParserValue::EndOfFile(pos)
});
helper.Tokens({CommandsParserValue::Identifier(pos, new std::string("architecture")),
CommandsParserValue::Identifier(pos, new std::string("x86")),
CommandsParserValue::Character(pos, ';'),
CommandsParserValue::EndOfFile(pos)});
auto result = helper.PerformTest();
@ -59,12 +57,10 @@ namespace test::parsing::commands::sequence::sequence_architecture
{
CommandsSequenceTestsHelper helper;
const TokenPos pos;
helper.Tokens({
CommandsParserValue::Identifier(pos, new std::string("architecture")),
CommandsParserValue::Identifier(pos, new std::string("x86")),
CommandsParserValue::Character(pos, ';'),
CommandsParserValue::EndOfFile(pos)
});
helper.Tokens({CommandsParserValue::Identifier(pos, new std::string("architecture")),
CommandsParserValue::Identifier(pos, new std::string("x86")),
CommandsParserValue::Character(pos, ';'),
CommandsParserValue::EndOfFile(pos)});
auto result = helper.PerformTest();
@ -77,14 +73,12 @@ namespace test::parsing::commands::sequence::sequence_architecture
{
CommandsSequenceTestsHelper helper;
const TokenPos pos;
helper.Tokens({
CommandsParserValue::Identifier(pos, new std::string("architecture")),
CommandsParserValue::Identifier(pos, new std::string("x1337")),
CommandsParserValue::Character(pos, ';'),
CommandsParserValue::EndOfFile(pos)
});
helper.Tokens({CommandsParserValue::Identifier(pos, new std::string("architecture")),
CommandsParserValue::Identifier(pos, new std::string("x1337")),
CommandsParserValue::Character(pos, ';'),
CommandsParserValue::EndOfFile(pos)});
REQUIRE_THROWS_AS(helper.PerformTest(), ParsingException);
REQUIRE(helper.m_repository->GetArchitecture() == Architecture::UNKNOWN);
}
}
} // namespace test::parsing::commands::sequence::sequence_architecture

View File

@ -1,10 +1,10 @@
#include <catch2/catch_test_macros.hpp>
#include <catch2/generators/catch_generators.hpp>
#include "Utils/ClassUtils.h"
#include "Parsing/Commands/Sequence/SequenceGame.h"
#include "Parsing/Mock/MockLexer.h"
#include "Persistence/InMemory/InMemoryRepository.h"
#include "Utils/ClassUtils.h"
#include <catch2/catch_test_macros.hpp>
#include <catch2/generators/catch_generators.hpp>
namespace test::parsing::commands::sequence::sequence_game
{
@ -41,12 +41,10 @@ namespace test::parsing::commands::sequence::sequence_game
{
CommandsSequenceTestsHelper helper;
const TokenPos pos;
helper.Tokens({
CommandsParserValue::Identifier(pos, new std::string("game")),
CommandsParserValue::Identifier(pos, new std::string("very_cool_game")),
CommandsParserValue::Character(pos, ';'),
CommandsParserValue::EndOfFile(pos)
});
helper.Tokens({CommandsParserValue::Identifier(pos, new std::string("game")),
CommandsParserValue::Identifier(pos, new std::string("very_cool_game")),
CommandsParserValue::Character(pos, ';'),
CommandsParserValue::EndOfFile(pos)});
auto result = helper.PerformTest();
@ -54,4 +52,4 @@ namespace test::parsing::commands::sequence::sequence_game
REQUIRE(helper.m_consumed_token_count == 3);
REQUIRE(helper.m_repository->GetGameName() == "very_cool_game");
}
}
} // namespace test::parsing::commands::sequence::sequence_game

View File

@ -1,10 +1,10 @@
#include <catch2/catch_test_macros.hpp>
#include <catch2/matchers/catch_matchers_floating_point.hpp>
#include <catch2/generators/catch_generators.hpp>
#include "Parsing/Header/Impl/HeaderLexer.h"
#include "Parsing/Mock/MockParserLineStream.h"
#include <catch2/catch_test_macros.hpp>
#include <catch2/generators/catch_generators.hpp>
#include <catch2/matchers/catch_matchers_floating_point.hpp>
using namespace Catch::Matchers;
namespace test::parsing::header::impl::header_lexer
@ -53,13 +53,7 @@ namespace test::parsing::header::impl::header_lexer
TEST_CASE("HeaderLexer: Ensure can parse simple hex numbers", "[parsing][header]")
{
const std::vector<std::string> lines
{
"0x1A4",
" 0xABC ",
" 0xAAA",
"0xBBB "
};
const std::vector<std::string> lines{"0x1A4", " 0xABC ", " 0xAAA", "0xBBB "};
MockParserLineStream mockStream(lines);
HeaderLexer lexer(&mockStream);
@ -74,12 +68,7 @@ namespace test::parsing::header::impl::header_lexer
TEST_CASE("HeaderLexer: Ensure can parse simple hex numbers surrounded by identifiers", "[parsing][header]")
{
const std::vector<std::string> lines
{
"abc 0xABC cba",
"aaa 0xAAA",
"0xBBB bbb"
};
const std::vector<std::string> lines{"abc 0xABC cba", "aaa 0xAAA", "0xBBB bbb"};
MockParserLineStream mockStream(lines);
HeaderLexer lexer(&mockStream);
@ -99,8 +88,7 @@ namespace test::parsing::header::impl::header_lexer
TEST_CASE("HeaderLexer: Ensure can parse simple hex numbers surrounded by symbols", "[parsing][header]")
{
const std::vector<std::string> lines
{
const std::vector<std::string> lines{
"0x25:0xABC,0x1a4",
};
@ -118,10 +106,7 @@ namespace test::parsing::header::impl::header_lexer
TEST_CASE("HeaderLexer: Ensure throws exception when parsing incomplete hex number", "[parsing][header]")
{
const std::vector<std::string> lines
{
"0x"
};
const std::vector<std::string> lines{"0x"};
MockParserLineStream mockStream(lines);
HeaderLexer lexer(&mockStream);
@ -131,11 +116,8 @@ namespace test::parsing::header::impl::header_lexer
TEST_CASE("HeaderLexer: Ensure throws exception when parsing invalid hex number", "[parsing][header]")
{
const std::vector<std::string> lines
{
"0xGEGE"
};
const std::vector<std::string> lines{"0xGEGE"};
MockParserLineStream mockStream(lines);
HeaderLexer lexer(&mockStream);
@ -144,10 +126,7 @@ namespace test::parsing::header::impl::header_lexer
TEST_CASE("HeaderLexer: Ensure throws exception when parsing invalid hex number that starts with a valid letter", "[parsing][header]")
{
const std::vector<std::string> lines
{
"0xEGEG"
};
const std::vector<std::string> lines{"0xEGEG"};
MockParserLineStream mockStream(lines);
HeaderLexer lexer(&mockStream);
@ -157,12 +136,7 @@ namespace test::parsing::header::impl::header_lexer
TEST_CASE("HeaderLexer: Ensure can parse simple integers", "[parsing][header]")
{
const std::vector<std::string> lines
{
" 524 ",
"4221111 1337 ",
"0 420"
};
const std::vector<std::string> lines{" 524 ", "4221111 1337 ", "0 420"};
MockParserLineStream mockStream(lines);
HeaderLexer lexer(&mockStream);
@ -176,12 +150,7 @@ namespace test::parsing::header::impl::header_lexer
TEST_CASE("HeaderLexer: Ensure can parse integers surrounded by identifiers", "[parsing][header]")
{
const std::vector<std::string> lines
{
"aa 6 bb",
"123456789 ccc",
"0 d 420"
};
const std::vector<std::string> lines{"aa 6 bb", "123456789 ccc", "0 d 420"};
MockParserLineStream mockStream(lines);
HeaderLexer lexer(&mockStream);
@ -198,28 +167,22 @@ namespace test::parsing::header::impl::header_lexer
TEST_CASE("HeaderLexer: Ensure parses negative numbers as character and number", "[parsing][header]")
{
const std::vector<std::string> lines
{
"-1337"
};
const std::vector<std::string> lines{"-1337"};
MockParserLineStream mockStream(lines);
HeaderLexer lexer(&mockStream);
ExpectCharacterToken(lexer, '-');
ExpectIntegerToken(lexer, 1337);
}
TEST_CASE("HeaderLexer: Ensure recognizes numbers surrounded by characters", "[parsing][header]")
{
const std::vector<std::string> lines
{
"(1337)"
};
const std::vector<std::string> lines{"(1337)"};
MockParserLineStream mockStream(lines);
HeaderLexer lexer(&mockStream);
ExpectCharacterToken(lexer, '(');
ExpectIntegerToken(lexer, 1337);
ExpectCharacterToken(lexer, ')');
@ -227,25 +190,17 @@ namespace test::parsing::header::impl::header_lexer
TEST_CASE("HeaderLexer: Ensure parses simple floating point numbers", "[parsing][header]")
{
const std::vector<std::string> lines
{
"420.1337"
};
const std::vector<std::string> lines{"420.1337"};
MockParserLineStream mockStream(lines);
HeaderLexer lexer(&mockStream);
ExpectFloatingPointToken(lexer, 420.1337);
}
TEST_CASE("HeaderLexer: Ensure parses simple floating point numbers surrounded by identifiers", "[parsing][header]")
{
const std::vector<std::string> lines
{
"aa 50.24 a",
"b 36.999",
"59595.2414 c"
};
const std::vector<std::string> lines{"aa 50.24 a", "b 36.999", "59595.2414 c"};
MockParserLineStream mockStream(lines);
HeaderLexer lexer(&mockStream);
@ -261,10 +216,7 @@ namespace test::parsing::header::impl::header_lexer
TEST_CASE("HeaderLexer: Ensure recognizes floating point numbers surrounded by characters", "[parsing][header]")
{
const std::vector<std::string> lines
{
"(1337.420)"
};
const std::vector<std::string> lines{"(1337.420)"};
MockParserLineStream mockStream(lines);
HeaderLexer lexer(&mockStream);
@ -276,10 +228,7 @@ namespace test::parsing::header::impl::header_lexer
TEST_CASE("HeaderLexer: Ensure can separate identifiers with symbols", "[parsing][header]")
{
const std::vector<std::string> lines
{
"hello|world hello_+universe"
};
const std::vector<std::string> lines{"hello|world hello_+universe"};
MockParserLineStream mockStream(lines);
HeaderLexer lexer(&mockStream);
@ -294,10 +243,7 @@ namespace test::parsing::header::impl::header_lexer
TEST_CASE("HeaderLexer: Can recognize shift left", "[parsing][header]")
{
const std::vector<std::string> lines
{
"<<hello<<world<<"
};
const std::vector<std::string> lines{"<<hello<<world<<"};
MockParserLineStream mockStream(lines);
HeaderLexer lexer(&mockStream);
@ -311,10 +257,7 @@ namespace test::parsing::header::impl::header_lexer
TEST_CASE("HeaderLexer: Can recognize less equals", "[parsing][header]")
{
const std::vector<std::string> lines
{
"<=hello<=world<="
};
const std::vector<std::string> lines{"<=hello<=world<="};
MockParserLineStream mockStream(lines);
HeaderLexer lexer(&mockStream);
@ -328,10 +271,7 @@ namespace test::parsing::header::impl::header_lexer
TEST_CASE("HeaderLexer: Can recognize less", "[parsing][header]")
{
const std::vector<std::string> lines
{
"<%hello<world<&"
};
const std::vector<std::string> lines{"<%hello<world<&"};
MockParserLineStream mockStream(lines);
HeaderLexer lexer(&mockStream);
@ -347,10 +287,7 @@ namespace test::parsing::header::impl::header_lexer
TEST_CASE("HeaderLexer: Can recognize shift right", "[parsing][header]")
{
const std::vector<std::string> lines
{
">>hello>>world>>"
};
const std::vector<std::string> lines{">>hello>>world>>"};
MockParserLineStream mockStream(lines);
HeaderLexer lexer(&mockStream);
@ -364,10 +301,7 @@ namespace test::parsing::header::impl::header_lexer
TEST_CASE("HeaderLexer: Can recognize greater equals", "[parsing][header]")
{
const std::vector<std::string> lines
{
">=hello>=world>="
};
const std::vector<std::string> lines{">=hello>=world>="};
MockParserLineStream mockStream(lines);
HeaderLexer lexer(&mockStream);
@ -381,10 +315,7 @@ namespace test::parsing::header::impl::header_lexer
TEST_CASE("HeaderLexer: Can recognize greater", "[parsing][header]")
{
const std::vector<std::string> lines
{
">%hello>world>&"
};
const std::vector<std::string> lines{">%hello>world>&"};
MockParserLineStream mockStream(lines);
HeaderLexer lexer(&mockStream);
@ -400,10 +331,7 @@ namespace test::parsing::header::impl::header_lexer
TEST_CASE("HeaderLexer: Can recognize equals", "[parsing][header]")
{
const std::vector<std::string> lines
{
"==hello==world=="
};
const std::vector<std::string> lines{"==hello==world=="};
MockParserLineStream mockStream(lines);
HeaderLexer lexer(&mockStream);
@ -417,10 +345,7 @@ namespace test::parsing::header::impl::header_lexer
TEST_CASE("HeaderLexer: Can recognize assign", "[parsing][header]")
{
const std::vector<std::string> lines
{
"=%hello=world=&"
};
const std::vector<std::string> lines{"=%hello=world=&"};
MockParserLineStream mockStream(lines);
HeaderLexer lexer(&mockStream);
@ -436,10 +361,7 @@ namespace test::parsing::header::impl::header_lexer
TEST_CASE("HeaderLexer: Can recognize logical and", "[parsing][header]")
{
const std::vector<std::string> lines
{
"&&hello&&world&&"
};
const std::vector<std::string> lines{"&&hello&&world&&"};
MockParserLineStream mockStream(lines);
HeaderLexer lexer(&mockStream);
@ -453,10 +375,7 @@ namespace test::parsing::header::impl::header_lexer
TEST_CASE("HeaderLexer: Can recognize ampersand", "[parsing][header]")
{
const std::vector<std::string> lines
{
"&%hello&world&+"
};
const std::vector<std::string> lines{"&%hello&world&+"};
MockParserLineStream mockStream(lines);
HeaderLexer lexer(&mockStream);
@ -472,10 +391,7 @@ namespace test::parsing::header::impl::header_lexer
TEST_CASE("HeaderLexer: Can recognize logical or", "[parsing][header]")
{
const std::vector<std::string> lines
{
"||hello||world||"
};
const std::vector<std::string> lines{"||hello||world||"};
MockParserLineStream mockStream(lines);
HeaderLexer lexer(&mockStream);
@ -489,10 +405,7 @@ namespace test::parsing::header::impl::header_lexer
TEST_CASE("HeaderLexer: Can recognize pipe", "[parsing][header]")
{
const std::vector<std::string> lines
{
"|%hello|world|&"
};
const std::vector<std::string> lines{"|%hello|world|&"};
MockParserLineStream mockStream(lines);
HeaderLexer lexer(&mockStream);
@ -508,10 +421,7 @@ namespace test::parsing::header::impl::header_lexer
TEST_CASE("HeaderLexer: Can recognize not equals", "[parsing][header]")
{
const std::vector<std::string> lines
{
"!=hello!=world!="
};
const std::vector<std::string> lines{"!=hello!=world!="};
MockParserLineStream mockStream(lines);
HeaderLexer lexer(&mockStream);
@ -525,10 +435,7 @@ namespace test::parsing::header::impl::header_lexer
TEST_CASE("HeaderLexer: Can recognize exclamation mark", "[parsing][header]")
{
const std::vector<std::string> lines
{
"!%hello!world!&"
};
const std::vector<std::string> lines{"!%hello!world!&"};
MockParserLineStream mockStream(lines);
HeaderLexer lexer(&mockStream);
@ -544,13 +451,7 @@ namespace test::parsing::header::impl::header_lexer
TEST_CASE("HeaderLexer: Can recognize strings", "[parsing][header]")
{
const std::vector<std::string> lines
{
"\"hello world\"",
"a\"hi there\"bbb",
" \"nice\"",
"\"meme\" "
};
const std::vector<std::string> lines{"\"hello world\"", "a\"hi there\"bbb", " \"nice\"", "\"meme\" "};
MockParserLineStream mockStream(lines);
HeaderLexer lexer(&mockStream);
@ -562,4 +463,4 @@ namespace test::parsing::header::impl::header_lexer
ExpectStringToken(lexer, "nice");
ExpectStringToken(lexer, "meme");
}
}
} // namespace test::parsing::header::impl::header_lexer

View File

@ -1,21 +1,20 @@
#include <catch2/catch_test_macros.hpp>
#include <catch2/generators/catch_generators.hpp>
#include "Parsing/Header/Sequence/SequenceNamespace.h"
#include "Parsing/Mock/MockLexer.h"
#include "Parsing/Mock/MockPackValueSupplier.h"
#include <catch2/catch_test_macros.hpp>
#include <catch2/generators/catch_generators.hpp>
namespace test::parsing::header::sequence::sequence_namespace
{
TEST_CASE("SequenceNamespace: Ensure can parse simple namespace directive", "[parsing][parsingstream]")
{
const TokenPos pos;
const auto lexer = std::make_unique<MockLexer<HeaderParserValue>>(MockLexer<HeaderParserValue>(
{
HeaderParserValue::Keyword(pos, HeaderParserValueType::NAMESPACE),
HeaderParserValue::Identifier(pos, new std::string("test_namespace")),
HeaderParserValue::Character(pos, '{')
}, HeaderParserValue::EndOfFile(pos)));
const auto lexer =
std::make_unique<MockLexer<HeaderParserValue>>(MockLexer<HeaderParserValue>({HeaderParserValue::Keyword(pos, HeaderParserValueType::NAMESPACE),
HeaderParserValue::Identifier(pos, new std::string("test_namespace")),
HeaderParserValue::Character(pos, '{')},
HeaderParserValue::EndOfFile(pos)));
const auto packValueSupplier = std::make_unique<MockPackValueSupplier>();
const auto sequence = std::make_unique<SequenceNamespace>();
@ -26,4 +25,4 @@ namespace test::parsing::header::sequence::sequence_namespace
REQUIRE(result);
}
}
} // namespace test::parsing::header::sequence::sequence_namespace

File diff suppressed because it is too large Load Diff