-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
UnitTests Added tests for BIT() and TRAP::Version 11/13/2024 | 24w46a3
- Loading branch information
Showing
5 changed files
with
74 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |