mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2026-01-19 23:11:50 +00:00
render zoneload header
This commit is contained in:
@@ -4,60 +4,42 @@
|
||||
#include <sstream>
|
||||
|
||||
#include "Domain/Computations/StructureComputations.h"
|
||||
#include "Internal/BaseTemplate.h"
|
||||
|
||||
#define LINE(x) DoIntendation(); m_out << x << "\n"
|
||||
|
||||
class AssetStructTestsTemplate::Internal
|
||||
class AssetStructTestsTemplate::Internal final : BaseTemplate
|
||||
{
|
||||
static constexpr const char* INTENDATION = " ";
|
||||
|
||||
std::ostream& m_out;
|
||||
RenderingContext& m_env;
|
||||
unsigned m_intendation;
|
||||
|
||||
void DoIntendation() const
|
||||
{
|
||||
for (auto i = 0u; i < m_intendation; i++)
|
||||
m_out << INTENDATION;
|
||||
}
|
||||
|
||||
void TestMethod(StructureInformation* structure)
|
||||
{
|
||||
/*if (structure->m_non_embedded_reference_exists)
|
||||
{*/
|
||||
LINE("TEST_CASE(\""<<m_env.m_game<<"::"<<m_env.m_asset->m_definition->GetFullName()<<": Tests for "<<structure->m_definition->GetFullName()<<"\", \"[assetstruct]\")");
|
||||
LINE("{");
|
||||
m_intendation++;
|
||||
LINE("REQUIRE("<<structure->m_definition->GetSize()<<"u == sizeof("<<structure->m_definition->GetFullName()<<"));");
|
||||
LINE("REQUIRE("<<structure->m_definition->GetAlignment()<<"u == alignof("<<structure->m_definition->GetFullName()<<"));");
|
||||
m_intendation--;
|
||||
LINE("}");
|
||||
/*}*/
|
||||
LINE("TEST_CASE(\""<<m_env.m_game<<"::"<<m_env.m_asset->m_definition->GetFullName()<<": Tests for "<<structure->m_definition->GetFullName()<<"\", \"[assetstruct]\")")
|
||||
LINE("{")
|
||||
m_intendation++;
|
||||
LINE("REQUIRE("<<structure->m_definition->GetSize()<<"u == sizeof("<<structure->m_definition->GetFullName()<<"));")
|
||||
LINE("REQUIRE("<<structure->m_definition->GetAlignment()<<"u == alignof("<<structure->m_definition->GetFullName()<<"));")
|
||||
m_intendation--;
|
||||
LINE("}")
|
||||
}
|
||||
|
||||
public:
|
||||
Internal(std::ostream& stream, RenderingContext* context)
|
||||
: m_out(stream),
|
||||
m_env(*context),
|
||||
m_intendation(0u)
|
||||
: BaseTemplate(stream, context)
|
||||
{
|
||||
}
|
||||
|
||||
void Source()
|
||||
{
|
||||
LINE("// ====================================================================");
|
||||
LINE("// This file has been generated by ZoneCodeGenerator.");
|
||||
LINE("// Do not modify.");
|
||||
LINE("// Any changes will be discarded when regenerating.");
|
||||
LINE("// ====================================================================");
|
||||
LINE("");
|
||||
LINE("#include <catch2/catch.hpp>");
|
||||
LINE("#include \"Game/" << m_env.m_game << "/" << m_env.m_game << ".h\"");
|
||||
LINE("");
|
||||
LINE("using namespace " << m_env.m_game << ";");
|
||||
LINE("");
|
||||
LINE("namespace game::"<<m_env.m_game<<"::xassets::asset_"<<m_env.m_asset->m_definition->m_name);
|
||||
LINE("{");
|
||||
LINE("// ====================================================================")
|
||||
LINE("// This file has been generated by ZoneCodeGenerator.")
|
||||
LINE("// Do not modify.")
|
||||
LINE("// Any changes will be discarded when regenerating.")
|
||||
LINE("// ====================================================================")
|
||||
LINE("")
|
||||
LINE("#include <catch2/catch.hpp>")
|
||||
LINE("#include \"Game/" << m_env.m_game << "/" << m_env.m_game << ".h\"")
|
||||
LINE("")
|
||||
LINE("using namespace " << m_env.m_game << ";")
|
||||
LINE("")
|
||||
LINE("namespace game::"<<m_env.m_game<<"::xassets::asset_"<<Lower(m_env.m_asset->m_definition->m_name))
|
||||
LINE("{")
|
||||
m_intendation++;
|
||||
|
||||
TestMethod(m_env.m_asset);
|
||||
@@ -69,7 +51,7 @@ public:
|
||||
}
|
||||
|
||||
m_intendation--;
|
||||
LINE("}");
|
||||
LINE("}")
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user