diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index c99567ba..66f8df70 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -82,6 +82,7 @@ jobs: - name: Test working-directory: ${{ github.workspace }}/build/lib/Release_${{ matrix.build_arch }}/tests run: | + ./CommonTests ./ObjCommonTests ./ObjCompilingTests ./ObjLoadingTests @@ -138,6 +139,8 @@ jobs: working-directory: ${{ github.workspace }}/build/lib/Release_${{ matrix.build_arch }}/tests run: | $combinedExitCode = 0 + ./CommonTests + $combinedExitCode = [System.Math]::max($combinedExitCode, $LASTEXITCODE) ./ObjCommonTests $combinedExitCode = [System.Math]::max($combinedExitCode, $LASTEXITCODE) ./ObjCompilingTests diff --git a/premake5.lua b/premake5.lua index 535668a0..5cfb7552 100644 --- a/premake5.lua +++ b/premake5.lua @@ -195,6 +195,7 @@ group "" -- Tests -- ======================== include "test/Catch2Common.lua" +include "test/CommonTests.lua" include "test/ObjCommonTestUtils.lua" include "test/ObjCommonTests.lua" include "test/ObjCompilingTests.lua" @@ -209,6 +210,7 @@ include "test/ZoneCommonTests.lua" -- Tests group: Unit test and other tests projects group "Tests" Catch2Common:project() + CommonTests:project() ObjCommonTestUtils:project() ObjCommonTests:project() ObjCompilingTests:project() diff --git a/test/CommonTests.lua b/test/CommonTests.lua new file mode 100644 index 00000000..6300f2b1 --- /dev/null +++ b/test/CommonTests.lua @@ -0,0 +1,54 @@ +CommonTests = {} + +function CommonTests:include(includes) + if includes:handle(self:name()) then + includedirs { + path.join(TestFolder(), "CommonTests") + } + end +end + +function CommonTests:link(links) + +end + +function CommonTests:use() + +end + +function CommonTests:name() + return "CommonTests" +end + +function CommonTests:project() + local folder = TestFolder() + local includes = Includes:create() + local links = Links:create() + + project(self:name()) + targetdir(TargetDirectoryTest) + location "%{wks.location}/test/%{prj.name}" + kind "ConsoleApp" + language "C++" + + files { + path.join(folder, "CommonTests/**.h"), + path.join(folder, "CommonTests/**.cpp") + } + + vpaths { + ["*"] = { + path.join(folder, "CommonTests") + } + } + + self:include(includes) + Catch2Common:include(includes) + Common:include(includes) + catch2:include(includes) + + links:linkto(Common) + links:linkto(catch2) + links:linkto(Catch2Common) + links:linkall() +end diff --git a/test/CommonTests/Game/IW3/CommonIW3Tests.cpp b/test/CommonTests/Game/IW3/CommonIW3Tests.cpp new file mode 100644 index 00000000..f3736fd1 --- /dev/null +++ b/test/CommonTests/Game/IW3/CommonIW3Tests.cpp @@ -0,0 +1,28 @@ +#include "Game/IW3/CommonIW3.h" + +#include +#include + +TEST_CASE("IW3: Check checksums", "[iw3]") +{ + SECTION("for R_HashString") + { + const auto [str, expectedHash] = GENERATE(Catch::Generators::table({ + {"hello world", 0xe7d74060}, + {"universe2", 0x113fdcd7}, + {"lit_r0c0n0x0_b1c1n1s1v1_b2c2n2x2", 0xdd0153c5}, + {"AngularVelocityScale", 0x18f2cb6d}, + {"BakedLightingIntensity", 0xd627f218}, + {"Layer1OffsetBobbleDelay", 0xcd91b6ae}, + {"MaxDepth", 0x61ed5959}, + {"MomentumColor", 0xc80f3595}, + {"SparkleScale", 0x5488816a}, + {"TickMarkColorAndHarshness", 0xd6c718bd}, + {"worldViewProjectionMatrix", 0x7f661409}, + })); + + CAPTURE(str); + const auto hash = IW3::Common::R_HashString(str); + REQUIRE(hash == expectedHash); + } +} diff --git a/test/CommonTests/Game/IW4/CommonIW4Tests.cpp b/test/CommonTests/Game/IW4/CommonIW4Tests.cpp new file mode 100644 index 00000000..b715c7f7 --- /dev/null +++ b/test/CommonTests/Game/IW4/CommonIW4Tests.cpp @@ -0,0 +1,49 @@ +#include "Game/IW4/CommonIW4.h" + +#include +#include + +TEST_CASE("IW4: Check checksums", "[iw4]") +{ + SECTION("for StringTable_HashString") + { + const auto [str, expectedHash] = GENERATE(Catch::Generators::table({ + {"hello world", 0x6aefe2c4}, + {"universe2", 0xe796fe8d}, + {"lit_r0c0n0x0_b1c1n1s1v1_b2c2n2x2", 0x16c4d3f1}, + {"AngularVelocityScale", 0x573e9feb}, + {"BakedLightingIntensity", 0x15af785c}, + {"Layer1OffsetBobbleDelay", 0xfb83324a}, + {"MaxDepth", 0x1892e3df}, + {"MomentumColor", 0x5e7abdcb}, + {"SparkleScale", 0x9e4409f4}, + {"TickMarkColorAndHarshness", 0x5dfe4c47}, + {"worldViewProjectionMatrix", 0xa2501a07}, + })); + + CAPTURE(str); + const auto hash = IW4::Common::StringTable_HashString(str); + REQUIRE(hash == expectedHash); + } + + SECTION("for R_HashString") + { + const auto [str, expectedHash] = GENERATE(Catch::Generators::table({ + {"hello world", 0xe7d74060}, + {"universe2", 0x113fdcd7}, + {"lit_r0c0n0x0_b1c1n1s1v1_b2c2n2x2", 0xdd0153c5}, + {"AngularVelocityScale", 0x18f2cb6d}, + {"BakedLightingIntensity", 0xd627f218}, + {"Layer1OffsetBobbleDelay", 0xcd91b6ae}, + {"MaxDepth", 0x61ed5959}, + {"MomentumColor", 0xc80f3595}, + {"SparkleScale", 0x5488816a}, + {"TickMarkColorAndHarshness", 0xd6c718bd}, + {"worldViewProjectionMatrix", 0x7f661409}, + })); + + CAPTURE(str); + const auto hash = IW4::Common::R_HashString(str); + REQUIRE(hash == expectedHash); + } +} diff --git a/test/CommonTests/Game/IW5/CommonIW5Tests.cpp b/test/CommonTests/Game/IW5/CommonIW5Tests.cpp new file mode 100644 index 00000000..804a8017 --- /dev/null +++ b/test/CommonTests/Game/IW5/CommonIW5Tests.cpp @@ -0,0 +1,49 @@ +#include "Game/IW5/CommonIW5.h" + +#include +#include + +TEST_CASE("IW5: Check checksums", "[iw5]") +{ + SECTION("for StringTable_HashString") + { + const auto [str, expectedHash] = GENERATE(Catch::Generators::table({ + {"hello world", 0x6aefe2c4}, + {"universe2", 0xe796fe8d}, + {"lit_r0c0n0x0_b1c1n1s1v1_b2c2n2x2", 0x16c4d3f1}, + {"AngularVelocityScale", 0x573e9feb}, + {"BakedLightingIntensity", 0x15af785c}, + {"Layer1OffsetBobbleDelay", 0xfb83324a}, + {"MaxDepth", 0x1892e3df}, + {"MomentumColor", 0x5e7abdcb}, + {"SparkleScale", 0x9e4409f4}, + {"TickMarkColorAndHarshness", 0x5dfe4c47}, + {"worldViewProjectionMatrix", 0xa2501a07}, + })); + + CAPTURE(str); + const auto hash = IW5::Common::StringTable_HashString(str); + REQUIRE(hash == expectedHash); + } + + SECTION("for R_HashString") + { + const auto [str, expectedHash] = GENERATE(Catch::Generators::table({ + {"hello world", 0xe7d74060}, + {"universe2", 0x113fdcd7}, + {"lit_r0c0n0x0_b1c1n1s1v1_b2c2n2x2", 0xdd0153c5}, + {"AngularVelocityScale", 0x18f2cb6d}, + {"BakedLightingIntensity", 0xd627f218}, + {"Layer1OffsetBobbleDelay", 0xcd91b6ae}, + {"MaxDepth", 0x61ed5959}, + {"MomentumColor", 0xc80f3595}, + {"SparkleScale", 0x5488816a}, + {"TickMarkColorAndHarshness", 0xd6c718bd}, + {"worldViewProjectionMatrix", 0x7f661409}, + })); + + CAPTURE(str); + const auto hash = IW5::Common::R_HashString(str); + REQUIRE(hash == expectedHash); + } +} diff --git a/test/CommonTests/Game/T5/CommonT5Tests.cpp b/test/CommonTests/Game/T5/CommonT5Tests.cpp new file mode 100644 index 00000000..f80bde83 --- /dev/null +++ b/test/CommonTests/Game/T5/CommonT5Tests.cpp @@ -0,0 +1,70 @@ +#include "Game/T5/CommonT5.h" + +#include +#include + +TEST_CASE("T5: Check checksums", "[t5]") +{ + SECTION("for Com_HashKey") + { + const auto [str, expectedHash] = GENERATE(Catch::Generators::table({ + {"hello world", 0x21c3f}, + {"universe2", 0x1be55}, + {"lit_r0c0n0x0_b1c1n1s1v1_b2c2n2x2", 0x56e0f}, + {"AngularVelocityScale", 0x4043a}, + {"BakedLightingIntensity", 0x47a5c}, + {"Layer1OffsetBobbleDelay", 0x47950}, + {"MaxDepth", 0x17ca1}, + {"MomentumColor", 0x2998e}, + {"SparkleScale", 0x24cea}, + {"TickMarkColorAndHarshness", 0x50d40}, + {"worldViewProjectionMatrix", 0x548c4}, + })); + + CAPTURE(str); + const auto hash = T5::Common::Com_HashKey(str, 64); + REQUIRE(hash == expectedHash); + } + + SECTION("for Com_HashString") + { + const auto [str, expectedHash] = GENERATE(Catch::Generators::table({ + {"hello world", 0x3551c8c1}, + {"universe2", 0x608d72a8}, + {"lit_r0c0n0x0_b1c1n1s1v1_b2c2n2x2", 0xf93c46aa}, + {"AngularVelocityScale", 0x2eb08fc6}, + {"BakedLightingIntensity", 0xd8fd95b9}, + {"Layer1OffsetBobbleDelay", 0x4166172f}, + {"MaxDepth", 0x5dc1dee0}, + {"MomentumColor", 0x21c79416}, + {"SparkleScale", 0x42f7ecdf}, + {"TickMarkColorAndHarshness", 0xbb5761dc}, + {"worldViewProjectionMatrix", 0x25962bfa}, + })); + + CAPTURE(str); + const auto hash = T5::Common::Com_HashString(str); + REQUIRE(hash == expectedHash); + } + + SECTION("for R_HashString") + { + const auto [str, expectedHash] = GENERATE(Catch::Generators::table({ + {"hello world", 0xe7d74060}, + {"universe2", 0x113fdcd7}, + {"lit_r0c0n0x0_b1c1n1s1v1_b2c2n2x2", 0xdd0153c5}, + {"AngularVelocityScale", 0x18f2cb6d}, + {"BakedLightingIntensity", 0xd627f218}, + {"Layer1OffsetBobbleDelay", 0xcd91b6ae}, + {"MaxDepth", 0x61ed5959}, + {"MomentumColor", 0xc80f3595}, + {"SparkleScale", 0x5488816a}, + {"TickMarkColorAndHarshness", 0xd6c718bd}, + {"worldViewProjectionMatrix", 0x7f661409}, + })); + + CAPTURE(str); + const auto hash = T5::Common::R_HashString(str); + REQUIRE(hash == expectedHash); + } +} diff --git a/test/CommonTests/Game/T6/CommonT6Tests.cpp b/test/CommonTests/Game/T6/CommonT6Tests.cpp new file mode 100644 index 00000000..872220bb --- /dev/null +++ b/test/CommonTests/Game/T6/CommonT6Tests.cpp @@ -0,0 +1,91 @@ +#include "Game/T6/CommonT6.h" + +#include +#include + +TEST_CASE("T6: Check checksums", "[t6]") +{ + SECTION("for Com_HashKey") + { + const auto [str, expectedHash] = GENERATE(Catch::Generators::table({ + {"hello world", 0x21c3f}, + {"universe2", 0x1be55}, + {"lit_r0c0n0x0_b1c1n1s1v1_b2c2n2x2", 0x56e0f}, + {"AngularVelocityScale", 0x4043a}, + {"BakedLightingIntensity", 0x47a5c}, + {"Layer1OffsetBobbleDelay", 0x47950}, + {"MaxDepth", 0x17ca1}, + {"MomentumColor", 0x2998e}, + {"SparkleScale", 0x24cea}, + {"TickMarkColorAndHarshness", 0x50d40}, + {"worldViewProjectionMatrix", 0x548c4}, + })); + + CAPTURE(str); + const auto hash = T6::Common::Com_HashKey(str, 64); + REQUIRE(hash == expectedHash); + } + + SECTION("for Com_HashString") + { + const auto [str, expectedHash] = GENERATE(Catch::Generators::table({ + {"hello world", 0x3551c8c1}, + {"universe2", 0x608d72a8}, + {"lit_r0c0n0x0_b1c1n1s1v1_b2c2n2x2", 0xf93c46aa}, + {"AngularVelocityScale", 0x2eb08fc6}, + {"BakedLightingIntensity", 0xd8fd95b9}, + {"Layer1OffsetBobbleDelay", 0x4166172f}, + {"MaxDepth", 0x5dc1dee0}, + {"MomentumColor", 0x21c79416}, + {"SparkleScale", 0x42f7ecdf}, + {"TickMarkColorAndHarshness", 0xbb5761dc}, + {"worldViewProjectionMatrix", 0x25962bfa}, + })); + + CAPTURE(str); + const auto hash = T6::Common::Com_HashString(str); + REQUIRE(hash == expectedHash); + } + + SECTION("for R_HashString") + { + const auto [str, expectedHash] = GENERATE(Catch::Generators::table({ + {"hello world", 0xe7d74060}, + {"universe2", 0x113fdcd7}, + {"lit_r0c0n0x0_b1c1n1s1v1_b2c2n2x2", 0xdd0153c5}, + {"AngularVelocityScale", 0x18f2cb6d}, + {"BakedLightingIntensity", 0xd627f218}, + {"Layer1OffsetBobbleDelay", 0xcd91b6ae}, + {"MaxDepth", 0x61ed5959}, + {"MomentumColor", 0xc80f3595}, + {"SparkleScale", 0x5488816a}, + {"TickMarkColorAndHarshness", 0xd6c718bd}, + {"worldViewProjectionMatrix", 0x7f661409}, + })); + + CAPTURE(str); + const auto hash = T6::Common::R_HashString(str); + REQUIRE(hash == expectedHash); + } + + SECTION("for SND_HashName") + { + const auto [str, expectedHash] = GENERATE(Catch::Generators::table({ + {"hello world", 0x9e420d7f}, + {"universe2", 0xee605328}, + {"lit_r0c0n0x0_b1c1n1s1v1_b2c2n2x2", 0xc38575b6}, + {"AngularVelocityScale", 0x0c032bd0}, + {"BakedLightingIntensity", 0x57f1a221}, + {"Layer1OffsetBobbleDelay", 0x4f640b85}, + {"MaxDepth", 0x50d1cae4}, + {"MomentumColor", 0xbcab7666}, + {"SparkleScale", 0x162259d9}, + {"TickMarkColorAndHarshness", 0xbf3d7a42}, + {"worldViewProjectionMatrix", 0x28db35e2}, + })); + + CAPTURE(str); + const auto hash = T6::Common::SND_HashName(str); + REQUIRE(hash == expectedHash); + } +}