diff --git a/src/ZoneCodeGeneratorLib/Generating/Templates/AssetStructTestsTemplate.cpp b/src/ZoneCodeGeneratorLib/Generating/Templates/AssetStructTestsTemplate.cpp index 58ef3e5f..2a98eef2 100644 --- a/src/ZoneCodeGeneratorLib/Generating/Templates/AssetStructTestsTemplate.cpp +++ b/src/ZoneCodeGeneratorLib/Generating/Templates/AssetStructTestsTemplate.cpp @@ -44,7 +44,8 @@ public: LINE("// Any changes will be discarded when regenerating.") LINE("// ====================================================================") LINE("") - LINE("#include ") + LINE("#include ") + LINE("#include ") LINE("#include ") LINE("#include \"Game/" << m_env.m_game << "/" << m_env.m_game << ".h\"") LINE("") diff --git a/test/ObjCommonTests.lua b/test/ObjCommonTests.lua index d30f2ae2..18dc9201 100644 --- a/test/ObjCommonTests.lua +++ b/test/ObjCommonTests.lua @@ -48,5 +48,6 @@ function ObjCommonTests:project() catch2:include(includes) links:linkto(ObjCommon) + links:linkto(catch2) links:linkall() end diff --git a/test/ObjCommonTests/Image/ImageFormatTests.cpp b/test/ObjCommonTests/Image/ImageFormatTests.cpp index b87a3d81..a87e1c32 100644 --- a/test/ObjCommonTests/Image/ImageFormatTests.cpp +++ b/test/ObjCommonTests/Image/ImageFormatTests.cpp @@ -1,4 +1,5 @@ -#include +#include +#include #include diff --git a/test/ObjCommonTests/Obj/Gdt/GdtTests.cpp b/test/ObjCommonTests/Obj/Gdt/GdtTests.cpp index 19392575..d8bfa8f2 100644 --- a/test/ObjCommonTests/Obj/Gdt/GdtTests.cpp +++ b/test/ObjCommonTests/Obj/Gdt/GdtTests.cpp @@ -1,4 +1,5 @@ -#include +#include +#include #include diff --git a/test/ObjCommonTests/main.cpp b/test/ObjCommonTests/main.cpp deleted file mode 100644 index 2380d6bf..00000000 --- a/test/ObjCommonTests/main.cpp +++ /dev/null @@ -1,2 +0,0 @@ -#define CATCH_CONFIG_MAIN -#include \ No newline at end of file diff --git a/test/ObjLoadingTests.lua b/test/ObjLoadingTests.lua index 94158af9..e50dec2b 100644 --- a/test/ObjLoadingTests.lua +++ b/test/ObjLoadingTests.lua @@ -49,5 +49,6 @@ function ObjLoadingTests:project() links:linkto(ParserTestUtils) links:linkto(ObjLoading) + links:linkto(catch2) links:linkall() end diff --git a/test/ObjLoadingTests/Game/IW4/Menu/MenuParsingIW4IT.cpp b/test/ObjLoadingTests/Game/IW4/Menu/MenuParsingIW4IT.cpp index c5103f8b..fcef909e 100644 --- a/test/ObjLoadingTests/Game/IW4/Menu/MenuParsingIW4IT.cpp +++ b/test/ObjLoadingTests/Game/IW4/Menu/MenuParsingIW4IT.cpp @@ -1,4 +1,6 @@ -#include +#include +#include +#include #include @@ -12,6 +14,7 @@ using namespace menu; using namespace IW4; using namespace std::literals; +using namespace Catch::Matchers; namespace test::game::iw4::menu::parsing::it { @@ -184,10 +187,10 @@ namespace test::game::iw4::menu::parsing::it REQUIRE(menu->fullScreen > 0); REQUIRE(menu->window.staticFlags & WINDOW_FLAG_SCREEN_SPACE); REQUIRE(menu->window.staticFlags & WINDOW_FLAG_DECORATION); - REQUIRE(menu->window.rect.x == Approx(420)); - REQUIRE(menu->window.rect.y == Approx(1337)); - REQUIRE(menu->window.rect.w == Approx(12)); - REQUIRE(menu->window.rect.h == Approx(64)); + 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); @@ -250,16 +253,16 @@ namespace test::game::iw4::menu::parsing::it REQUIRE(menu->onESC->eventHandlers[0]->eventData.unconditionalScript == R"("setColor" "1" "0.5" "0.1" "1" ; )"s); REQUIRE(menu->window.border == 1); - REQUIRE(menu->window.borderSize == Approx(1.25)); - REQUIRE(menu->window.borderSize == Approx(1.25)); - REQUIRE(menu->window.backColor[0] == Approx(1)); - REQUIRE(menu->window.backColor[1] == Approx(0.8)); - REQUIRE(menu->window.backColor[2] == Approx(0.4)); - REQUIRE(menu->window.backColor[3] == Approx(0.95)); - REQUIRE(menu->window.foreColor[0] == Approx(0.7)); - REQUIRE(menu->window.foreColor[1] == Approx(0)); - REQUIRE(menu->window.foreColor[2] == Approx(0)); - REQUIRE(menu->window.foreColor[3] == Approx(0)); + 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); diff --git a/test/ObjLoadingTests/Parsing/Menu/Sequence/EventHandlerSetScopeSequencesTests.cpp b/test/ObjLoadingTests/Parsing/Menu/Sequence/EventHandlerSetScopeSequencesTests.cpp index 4e1dab43..9c5c0751 100644 --- a/test/ObjLoadingTests/Parsing/Menu/Sequence/EventHandlerSetScopeSequencesTests.cpp +++ b/test/ObjLoadingTests/Parsing/Menu/Sequence/EventHandlerSetScopeSequencesTests.cpp @@ -1,4 +1,5 @@ -#include +#include +#include #include "Parsing/Menu/Domain/EventHandler/CommonEventHandlerScript.h" #include "Parsing/Menu/Domain/EventHandler/CommonEventHandlerSetLocalVar.h" diff --git a/test/ObjLoadingTests/Parsing/Menu/Sequence/ItemScopeSequencesTests.cpp b/test/ObjLoadingTests/Parsing/Menu/Sequence/ItemScopeSequencesTests.cpp index 9262db82..e15e8764 100644 --- a/test/ObjLoadingTests/Parsing/Menu/Sequence/ItemScopeSequencesTests.cpp +++ b/test/ObjLoadingTests/Parsing/Menu/Sequence/ItemScopeSequencesTests.cpp @@ -1,4 +1,5 @@ -#include +#include +#include #include "Utils/ClassUtils.h" #include "Parsing/Menu/Sequence/ItemScopeSequences.h" diff --git a/test/ObjLoadingTests/main.cpp b/test/ObjLoadingTests/main.cpp deleted file mode 100644 index 2380d6bf..00000000 --- a/test/ObjLoadingTests/main.cpp +++ /dev/null @@ -1,2 +0,0 @@ -#define CATCH_CONFIG_MAIN -#include \ No newline at end of file diff --git a/test/ParserTestUtils.lua b/test/ParserTestUtils.lua index 8585bf8b..4137d524 100644 --- a/test/ParserTestUtils.lua +++ b/test/ParserTestUtils.lua @@ -48,5 +48,6 @@ function ParserTestUtils:project() catch2:include(includes) links:linkto(Parser) + links:linkto(catch2) links:linkall() end diff --git a/test/ParserTests.lua b/test/ParserTests.lua index 7e8cb35f..bc19f2de 100644 --- a/test/ParserTests.lua +++ b/test/ParserTests.lua @@ -49,5 +49,6 @@ function ParserTests:project() links:linkto(ParserTestUtils) links:linkto(Parser) + links:linkto(catch2) links:linkall() end diff --git a/test/ParserTests/Parsing/Impl/CommentRemovingStreamProxyTests.cpp b/test/ParserTests/Parsing/Impl/CommentRemovingStreamProxyTests.cpp index 4842a724..af6fca37 100644 --- a/test/ParserTests/Parsing/Impl/CommentRemovingStreamProxyTests.cpp +++ b/test/ParserTests/Parsing/Impl/CommentRemovingStreamProxyTests.cpp @@ -1,4 +1,5 @@ -#include +#include +#include #include "Parsing/Impl/CommentRemovingStreamProxy.h" #include "Parsing/Mock/MockParserLineStream.h" diff --git a/test/ParserTests/Parsing/Impl/DefinesStreamProxyTests.cpp b/test/ParserTests/Parsing/Impl/DefinesStreamProxyTests.cpp index f3d1a968..ba3d53ce 100644 --- a/test/ParserTests/Parsing/Impl/DefinesStreamProxyTests.cpp +++ b/test/ParserTests/Parsing/Impl/DefinesStreamProxyTests.cpp @@ -1,4 +1,5 @@ -#include +#include +#include #include "Parsing/Impl/DefinesStreamProxy.h" #include "Parsing/Mock/MockParserLineStream.h" diff --git a/test/ParserTests/Parsing/Impl/IncludingStreamProxyTests.cpp b/test/ParserTests/Parsing/Impl/IncludingStreamProxyTests.cpp index b726f0e2..13f32933 100644 --- a/test/ParserTests/Parsing/Impl/IncludingStreamProxyTests.cpp +++ b/test/ParserTests/Parsing/Impl/IncludingStreamProxyTests.cpp @@ -1,4 +1,5 @@ -#include +#include +#include #include "Parsing/Impl/IncludingStreamProxy.h" #include "Parsing/Mock/MockParserLineStream.h" diff --git a/test/ParserTests/Parsing/Impl/PackDefinitionStreamProxyTests.cpp b/test/ParserTests/Parsing/Impl/PackDefinitionStreamProxyTests.cpp index def2f9e7..7f85f4e5 100644 --- a/test/ParserTests/Parsing/Impl/PackDefinitionStreamProxyTests.cpp +++ b/test/ParserTests/Parsing/Impl/PackDefinitionStreamProxyTests.cpp @@ -1,4 +1,5 @@ -#include +#include +#include #include "Parsing/Impl/PackDefinitionStreamProxy.h" #include "Parsing/Mock/MockParserLineStream.h" diff --git a/test/ParserTests/Parsing/Simple/SimpleExpressionTests.cpp b/test/ParserTests/Parsing/Simple/SimpleExpressionTests.cpp index c7dfada4..f9484977 100644 --- a/test/ParserTests/Parsing/Simple/SimpleExpressionTests.cpp +++ b/test/ParserTests/Parsing/Simple/SimpleExpressionTests.cpp @@ -1,4 +1,5 @@ -#include +#include +#include #include diff --git a/test/ParserTests/main.cpp b/test/ParserTests/main.cpp deleted file mode 100644 index 2380d6bf..00000000 --- a/test/ParserTests/main.cpp +++ /dev/null @@ -1,2 +0,0 @@ -#define CATCH_CONFIG_MAIN -#include \ No newline at end of file diff --git a/test/ZoneCodeGeneratorLibTests.lua b/test/ZoneCodeGeneratorLibTests.lua index 54b64c01..bb8679a1 100644 --- a/test/ZoneCodeGeneratorLibTests.lua +++ b/test/ZoneCodeGeneratorLibTests.lua @@ -49,5 +49,6 @@ function ZoneCodeGeneratorLibTests:project() links:linkto(ZoneCodeGeneratorLib) links:linkto(ParserTestUtils) + links:linkto(catch2) links:linkall() end diff --git a/test/ZoneCodeGeneratorLibTests/Parsing/Commands/Impl/CommandsLexerTests.cpp b/test/ZoneCodeGeneratorLibTests/Parsing/Commands/Impl/CommandsLexerTests.cpp index 9bee8b00..8f5ed417 100644 --- a/test/ZoneCodeGeneratorLibTests/Parsing/Commands/Impl/CommandsLexerTests.cpp +++ b/test/ZoneCodeGeneratorLibTests/Parsing/Commands/Impl/CommandsLexerTests.cpp @@ -1,4 +1,5 @@ -#include +#include +#include #include "Parsing/Commands/Impl/CommandsLexer.h" #include "Parsing/Mock/MockParserLineStream.h" diff --git a/test/ZoneCodeGeneratorLibTests/Parsing/Commands/Sequence/SequenceActionTests.cpp b/test/ZoneCodeGeneratorLibTests/Parsing/Commands/Sequence/SequenceActionTests.cpp index 0488aba2..f801b59d 100644 --- a/test/ZoneCodeGeneratorLibTests/Parsing/Commands/Sequence/SequenceActionTests.cpp +++ b/test/ZoneCodeGeneratorLibTests/Parsing/Commands/Sequence/SequenceActionTests.cpp @@ -1,4 +1,5 @@ -#include +#include +#include #include "Utils/ClassUtils.h" #include "Parsing/Commands/Sequence/SequenceAction.h" diff --git a/test/ZoneCodeGeneratorLibTests/Parsing/Commands/Sequence/SequenceArchitectureTests.cpp b/test/ZoneCodeGeneratorLibTests/Parsing/Commands/Sequence/SequenceArchitectureTests.cpp index 997f401c..12e7518d 100644 --- a/test/ZoneCodeGeneratorLibTests/Parsing/Commands/Sequence/SequenceArchitectureTests.cpp +++ b/test/ZoneCodeGeneratorLibTests/Parsing/Commands/Sequence/SequenceArchitectureTests.cpp @@ -1,4 +1,5 @@ -#include +#include +#include #include "Utils/ClassUtils.h" #include "Parsing/Commands/Sequence/SequenceArchitecture.h" diff --git a/test/ZoneCodeGeneratorLibTests/Parsing/Commands/Sequence/SequenceGameTests.cpp b/test/ZoneCodeGeneratorLibTests/Parsing/Commands/Sequence/SequenceGameTests.cpp index 2279f2ea..03cc85c6 100644 --- a/test/ZoneCodeGeneratorLibTests/Parsing/Commands/Sequence/SequenceGameTests.cpp +++ b/test/ZoneCodeGeneratorLibTests/Parsing/Commands/Sequence/SequenceGameTests.cpp @@ -1,4 +1,5 @@ -#include +#include +#include #include "Utils/ClassUtils.h" #include "Parsing/Commands/Sequence/SequenceGame.h" diff --git a/test/ZoneCodeGeneratorLibTests/Parsing/Header/Impl/HeaderLexerTests.cpp b/test/ZoneCodeGeneratorLibTests/Parsing/Header/Impl/HeaderLexerTests.cpp index df8530b8..266c0055 100644 --- a/test/ZoneCodeGeneratorLibTests/Parsing/Header/Impl/HeaderLexerTests.cpp +++ b/test/ZoneCodeGeneratorLibTests/Parsing/Header/Impl/HeaderLexerTests.cpp @@ -1,8 +1,12 @@ -#include +#include +#include +#include #include "Parsing/Header/Impl/HeaderLexer.h" #include "Parsing/Mock/MockParserLineStream.h" +using namespace Catch::Matchers; + namespace test::parsing::header::impl::header_lexer { void ExpectCharacterToken(HeaderLexer& lexer, char c) @@ -22,7 +26,8 @@ namespace test::parsing::header::impl::header_lexer void ExpectFloatingPointToken(HeaderLexer& lexer, double number) { REQUIRE(lexer.GetToken(0).m_type == HeaderParserValueType::FLOATING_POINT); - REQUIRE(lexer.GetToken(0).FloatingPointValue() == Approx(number)); + const auto a = lexer.GetToken(0).FloatingPointValue(); + REQUIRE_THAT(lexer.GetToken(0).FloatingPointValue(), WithinRel(number)); lexer.PopTokens(1); } diff --git a/test/ZoneCodeGeneratorLibTests/Parsing/Header/Sequence/SequenceNamespaceTests.cpp b/test/ZoneCodeGeneratorLibTests/Parsing/Header/Sequence/SequenceNamespaceTests.cpp index 919b7055..3497dbd4 100644 --- a/test/ZoneCodeGeneratorLibTests/Parsing/Header/Sequence/SequenceNamespaceTests.cpp +++ b/test/ZoneCodeGeneratorLibTests/Parsing/Header/Sequence/SequenceNamespaceTests.cpp @@ -1,4 +1,5 @@ -#include +#include +#include #include "Parsing/Header/Sequence/SequenceNamespace.h" #include "Parsing/Mock/MockLexer.h" diff --git a/test/ZoneCodeGeneratorLibTests/Parsing/Matcher/MatcherTests.cpp b/test/ZoneCodeGeneratorLibTests/Parsing/Matcher/MatcherTests.cpp index e6fbf3e2..d04e23f5 100644 --- a/test/ZoneCodeGeneratorLibTests/Parsing/Matcher/MatcherTests.cpp +++ b/test/ZoneCodeGeneratorLibTests/Parsing/Matcher/MatcherTests.cpp @@ -1,5 +1,7 @@ -#include +#include +#include +#include #include #include "Utils/ClassUtils.h" diff --git a/test/ZoneCodeGeneratorLibTests/main.cpp b/test/ZoneCodeGeneratorLibTests/main.cpp deleted file mode 100644 index 2380d6bf..00000000 --- a/test/ZoneCodeGeneratorLibTests/main.cpp +++ /dev/null @@ -1,2 +0,0 @@ -#define CATCH_CONFIG_MAIN -#include \ No newline at end of file diff --git a/test/ZoneCommonTests.lua b/test/ZoneCommonTests.lua index f256dcc5..43af18ab 100644 --- a/test/ZoneCommonTests.lua +++ b/test/ZoneCommonTests.lua @@ -49,6 +49,7 @@ function ZoneCommonTests:project() catch2:include(includes) links:linkto(ZoneCommon) + links:linkto(catch2) links:linkall() ZoneCode:use() diff --git a/test/ZoneCommonTests/main.cpp b/test/ZoneCommonTests/main.cpp deleted file mode 100644 index 2380d6bf..00000000 --- a/test/ZoneCommonTests/main.cpp +++ /dev/null @@ -1,2 +0,0 @@ -#define CATCH_CONFIG_MAIN -#include \ No newline at end of file diff --git a/thirdparty/catch2 b/thirdparty/catch2 index de6fe184..3f0283de 160000 --- a/thirdparty/catch2 +++ b/thirdparty/catch2 @@ -1 +1 @@ -Subproject commit de6fe184a9ac1a06895cdd1c9b437f0a0bdf14ad +Subproject commit 3f0283de7a9c43200033da996ff9093be3ac84dc diff --git a/thirdparty/catch2.lua b/thirdparty/catch2.lua index 254a024d..f43d7205 100644 --- a/thirdparty/catch2.lua +++ b/thirdparty/catch2.lua @@ -3,12 +3,14 @@ catch2 = {} function catch2:include(includes) if includes:handle(self:name()) then includedirs { - path.join(ThirdPartyFolder(), "catch2", "single_include") + path.join(ThirdPartyFolder(), "catch2", "src"), + "%{wks.location}/thirdparty/catch2" } end end -function catch2:link() +function catch2:link(links) + links:add(self:name()) end function catch2:use() @@ -20,4 +22,63 @@ function catch2:name() end function catch2:project() + local folder = ThirdPartyFolder() + local includes = Includes:create() + + self:writeUserConfig() + + project(self:name()) + targetdir(TargetDirectoryLib) + location "%{wks.location}/thirdparty/%{prj.name}" + kind "StaticLib" + language "C++" + + files { + path.join(folder, "catch2/src/**.cpp"), + path.join(folder, "catch2/src/**.hpp"), + "%{wks.location}/thirdparty/%{prj.name}/**.cpp", + "%{wks.location}/thirdparty/%{prj.name}/**.hpp" + } + + vpaths { + ["*"] = { + path.join(folder, "catch2/src"), + "%{wks.location}/thirdparty/%{prj.name}" + } + } + + defines { + "DO_NOT_USE_WMAIN", + "_CRT_SECURE_NO_WARNINGS" + } + + self:include(includes) + + -- Disable warnings. They do not have any value to us since it is not our code. + warnings "off" end + +function catch2:writeUserConfig() + local folder = ThirdPartyFolder() + local inputFileName = path.join(folder, "catch2/src/catch2/catch_user_config.hpp.in") + local outputFileName = path.getabsolute("build/thirdparty/catch2/catch2/catch_user_config.hpp") + + local inputInfo = os.stat(inputFileName) + local outputInfo = os.stat(outputFileName) + + if inputInfo == nil then + return + end + + if outputInfo ~= nil and inputInfo.mtime <= outputInfo.mtime then + return + end + + local fileData = io.readfile(inputFileName) + fileData = string.gsub(fileData, '#cmakedefine[^\n]*', '') + fileData = string.gsub(fileData, '@CATCH_CONFIG_CONSOLE_WIDTH@', '80') + fileData = string.gsub(fileData, '@CATCH_CONFIG_DEFAULT_REPORTER@', 'console') + + os.mkdir(path.getdirectory(outputFileName)) + os.writefile_ifnotequal(fileData, outputFileName) +end \ No newline at end of file