Skip to content

Commit

Permalink
UnitTests Added tests for BIT() and TRAP::Version 11/13/2024 | 24w46a3
Browse files Browse the repository at this point in the history
  • Loading branch information
GamesTrap committed Nov 13, 2024
1 parent 076e47d commit 960134e
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 2 deletions.
4 changes: 4 additions & 0 deletions SITREPS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5377,3 +5377,7 @@ SITREP 11/11/2024|24w46a1
SITREP 11/12/2024|24w46a2
- Changed TRAP Engine version to 24w46a2(0.11.40)
- UnitTests Improved test coverage ~>20 mins

SITREP 11/13/2024|24w46a3
- Changed TRAP Engine version to 24w46a3(0.11.41)
- UnitTests Added tests for BIT() and TRAP::Version ~<5 mins
2 changes: 1 addition & 1 deletion TRAP/src/Core/Base.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
//-------------------------------------------------------------------------------------------------------------------//

/// @brief TRAP version number created with TRAP_MAKE_VERSION
inline constexpr TRAP::SemanticVersion<0, 11, 40> TRAP_VERSION{};
inline constexpr TRAP::SemanticVersion<0, 11, 41> TRAP_VERSION{};

//-------------------------------------------------------------------------------------------------------------------//

Expand Down
2 changes: 1 addition & 1 deletion TRAP/src/Log/Log.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ namespace TRAP
/// @threadsafe
void Clear() noexcept;

static constexpr auto WindowVersion = "[24w46a2]";
static constexpr auto WindowVersion = "[24w46a3]";
static constexpr auto WindowPrefix = "[Window] ";
static constexpr auto WindowIconPrefix = "[Window][Icon] ";
static constexpr auto ConfigPrefix = "[Config] ";
Expand Down
14 changes: 14 additions & 0 deletions UnitTests/src/Core/Base.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include <catch2/catch_test_macros.hpp>

#include "TRAP/src/Core/Base.h"

TEST_CASE("BIT()", "[core][bit]")
{
STATIC_REQUIRE(BIT(0u) == 1u);
STATIC_REQUIRE(BIT(1u) == 2u);
STATIC_REQUIRE(BIT(2u) == 4u);
STATIC_REQUIRE(BIT(4u) == 16u);
STATIC_REQUIRE(BIT(8u) == 256u);
STATIC_REQUIRE(BIT(16u) == 65536u);
STATIC_REQUIRE(BIT(31u) == 2147483648u);
}
54 changes: 54 additions & 0 deletions UnitTests/src/Core/Version.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#include <catch2/catch_test_macros.hpp>

#include "TRAP/src/Core/Version.h"

TEST_CASE("TRAP::SemanticVersion", "[core][semanticversion]")
{
SECTION("PreReleaseIdentifier()")
{
static constexpr TRAP::SemanticVersion<1u, 0u, 0u> ver1{};
STATIC_REQUIRE_FALSE(ver1.PreReleaseIdentifier());

static constexpr std::string_view PreReleaseIdentifier = "preRelease";
static constexpr TRAP::SemanticVersion<1u, 0u, 0u> ver2{PreReleaseIdentifier};
STATIC_REQUIRE(ver2.PreReleaseIdentifier());
STATIC_REQUIRE(*ver2.PreReleaseIdentifier() == PreReleaseIdentifier);

static constexpr std::string_view MetadataIdentifier = "metadata";
static constexpr TRAP::SemanticVersion<1u, 0u, 0u> ver3{PreReleaseIdentifier, MetadataIdentifier};
STATIC_REQUIRE(ver3.PreReleaseIdentifier());
STATIC_REQUIRE(*ver3.PreReleaseIdentifier() == PreReleaseIdentifier);
}

SECTION("MetadataIdentifier()")
{
static constexpr TRAP::SemanticVersion<1u, 0u, 0u> ver1{};
STATIC_REQUIRE_FALSE(ver1.MetadataIdentifier());

static constexpr std::string_view PreReleaseIdentifier = "preRelease";
static constexpr TRAP::SemanticVersion<1u, 0u, 0u> ver2{PreReleaseIdentifier};
STATIC_REQUIRE_FALSE(ver2.MetadataIdentifier());

static constexpr std::string_view MetadataIdentifier = "metadata";
static constexpr TRAP::SemanticVersion<1u, 0u, 0u> ver3{PreReleaseIdentifier, MetadataIdentifier};
STATIC_REQUIRE(ver3.PreReleaseIdentifier());
STATIC_REQUIRE(*ver3.MetadataIdentifier() == MetadataIdentifier);
}

SECTION("format specialization")
{
static constexpr TRAP::SemanticVersion<1u, 10u, 3u> ver1{};
const std::string expected1 = fmt::format("{}.{}.{}", ver1.Major(), ver1.Minor(), ver1.Patch());
REQUIRE(fmt::format("{}", ver1) == expected1);

static constexpr std::string_view PreReleaseIdentifier = "preRelease";
static constexpr TRAP::SemanticVersion<1u, 10u, 3u> ver2{PreReleaseIdentifier};
const std::string expected2 = fmt::format("{}.{}.{}-{}", ver1.Major(), ver1.Minor(), ver1.Patch(), PreReleaseIdentifier);
REQUIRE(fmt::format("{}", ver2) == expected2);

static constexpr std::string_view MetadataIdentifier = "metadata";
static constexpr TRAP::SemanticVersion<1u, 10u, 3u> ver3{PreReleaseIdentifier, MetadataIdentifier};
const std::string expected3 = fmt::format("{}.{}.{}-{}+{}", ver1.Major(), ver1.Minor(), ver1.Patch(), PreReleaseIdentifier, MetadataIdentifier);
REQUIRE(fmt::format("{}", ver3) == expected3);
}
}

0 comments on commit 960134e

Please sign in to comment.