Skip to content

Commit

Permalink
UnitTests Improved test coverage 11/12/2024 | 24w46a2
Browse files Browse the repository at this point in the history
  • Loading branch information
GamesTrap committed Nov 12, 2024
1 parent ad6674c commit 03d1534
Show file tree
Hide file tree
Showing 8 changed files with 1,337 additions and 9 deletions.
4 changes: 4 additions & 0 deletions SITREPS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5373,3 +5373,7 @@ SITREP 11/06/2024|24w45a3
SITREP 11/11/2024|24w46a1
- Changed TRAP Engine version to 24w46a1(0.11.39)
- UnitTests Refactored tests to use type parameter tests from Catch2 ~>120 mins

SITREP 11/12/2024|24w46a2
- Changed TRAP Engine version to 24w46a2(0.11.40)
- UnitTests Improved test coverage ~>20 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, 39> TRAP_VERSION{};
inline constexpr TRAP::SemanticVersion<0, 11, 40> 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 = "[24w46a1]";
static constexpr auto WindowVersion = "[24w46a2]";
static constexpr auto WindowPrefix = "[Window] ";
static constexpr auto WindowIconPrefix = "[Window][Icon] ";
static constexpr auto ConfigPrefix = "[Config] ";
Expand Down
2 changes: 1 addition & 1 deletion TRAP/src/Utils/ImageUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ namespace TRAP::Utils

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

/// @brief Decode BGRA indexed pixel data to RGBA.
/// @brief Decode indexed pixel data.
/// Output format depends on channel count, if it is 4, output is RGBA, if it is 3, output is RGB and so on.
/// @param source Indexed BGRA pixel data.
/// @param width Width of the image.
Expand Down
1,187 changes: 1,187 additions & 0 deletions UnitTests/Testfiles/Utils/ImageUtils_Src.h

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions UnitTests/src/FileSystem/FileSystemWatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ namespace
fsWatcher.AddFolder(p).wait();
}
fsWatcher.AddFolder("").wait();
fsWatcher.AddFolder("asdasdasdasdasdasdasdasdasdasdasd").wait();

const auto fsFolders = fsWatcher.GetFolders();
if(recursive)
Expand Down
3 changes: 3 additions & 0 deletions UnitTests/src/Log/Log.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ TEST_CASE("TRAP::Log", "[log]")

log.SetFilePath(LogFilePath);
REQUIRE(log.GetFilePath() == LogFilePath);

log.SetFilePath("");
REQUIRE(log.GetFilePath() == LogFilePath);
}

SECTION("TRAP::Log::GetImportanceLevel()")
Expand Down
145 changes: 139 additions & 6 deletions UnitTests/src/Utils/ImageUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ namespace
if(flippedPixelData.size() != expectedPixelData.size())
return false;

if(!std::equal(flippedPixelData.begin(), flippedPixelData.end(), expectedPixelData.begin()))
if(!std::ranges::equal(flippedPixelData, expectedPixelData))
return false;

return true;
Expand All @@ -75,7 +75,7 @@ namespace
if(flippedPixelData.size() != expectedPixelData.size())
return false;

if(!std::equal(flippedPixelData.begin(), flippedPixelData.end(), expectedPixelData.begin()))
if(!std::ranges::equal(flippedPixelData, expectedPixelData))
return false;

return true;
Expand All @@ -92,7 +92,7 @@ namespace
if(flippedPixelData.size() != expectedPixelData.size())
return false;

if(!std::equal(flippedPixelData.begin(), flippedPixelData.end(), expectedPixelData.begin()))
if(!std::ranges::equal(flippedPixelData, expectedPixelData))
return false;

return true;
Expand All @@ -109,7 +109,7 @@ namespace
if(flippedPixelData.size() != expectedPixelData.size())
return false;

if(!std::equal(flippedPixelData.begin(), flippedPixelData.end(), expectedPixelData.begin()))
if(!std::ranges::equal(flippedPixelData, expectedPixelData))
return false;

return true;
Expand All @@ -126,7 +126,7 @@ namespace
if(convertedPixelData.size() != (width * height * 4u))
return false;

if(!std::equal(convertedPixelData.begin(), convertedPixelData.end(), expectedPixelData.begin()))
if(!std::ranges::equal(convertedPixelData, expectedPixelData))
return false;

return true;
Expand All @@ -143,7 +143,7 @@ namespace
if(convertedPixelData.size() != (width * height * 3u))
return false;

if(!std::equal(convertedPixelData.begin(), convertedPixelData.end(), expectedPixelData.begin()))
if(!std::ranges::equal(convertedPixelData, expectedPixelData))
return false;

return true;
Expand Down Expand Up @@ -190,6 +190,17 @@ TEST_CASE("TRAP::Utils::FlipPixelDataX()", "[utils][imageutils]")
{
STATIC_REQUIRE(CheckFlipX<f32>(32u, 32u, 3u, TestImageHDRPixelDataRGB, TestImageHDRPixelDataRGBFlippedX));
}

SECTION("Invalid")
{
STATIC_REQUIRE(TRAP::Utils::FlipPixelDataX<u8>(0u, 2u, 4u, {}).empty());
STATIC_REQUIRE(TRAP::Utils::FlipPixelDataX<u8>(2u, 0u, 4u, {}).empty());
STATIC_REQUIRE(TRAP::Utils::FlipPixelDataX<u8>(2u, 2u, 0u, {}).empty());

STATIC_REQUIRE(TRAP::Utils::FlipPixelDataX<u8>(2u, 2u, 100u, {}).empty());

STATIC_REQUIRE(TRAP::Utils::FlipPixelDataX<u8>(2u, 2u, 4u, {}).empty());
}
}

TEST_CASE("TRAP::Utils::FlipPixelDataY()", "[utils][imageutils]")
Expand Down Expand Up @@ -228,6 +239,17 @@ TEST_CASE("TRAP::Utils::FlipPixelDataY()", "[utils][imageutils]")
{
STATIC_REQUIRE(CheckFlipY<f32>(32u, 32u, 3u, TestImageHDRPixelDataRGB, TestImageHDRPixelDataRGBFlippedY));
}

SECTION("Invalid")
{
STATIC_REQUIRE(TRAP::Utils::FlipPixelDataY<u8>(0u, 2u, 4u, {}).empty());
STATIC_REQUIRE(TRAP::Utils::FlipPixelDataY<u8>(2u, 0u, 4u, {}).empty());
STATIC_REQUIRE(TRAP::Utils::FlipPixelDataY<u8>(2u, 2u, 0u, {}).empty());

STATIC_REQUIRE(TRAP::Utils::FlipPixelDataY<u8>(2u, 2u, 100u, {}).empty());

STATIC_REQUIRE(TRAP::Utils::FlipPixelDataY<u8>(2u, 2u, 4u, {}).empty());
}
}

TEST_CASE("TRAP::Utils::RotatePixelData90Clockwise()", "[utils][imageutils]")
Expand Down Expand Up @@ -266,6 +288,17 @@ TEST_CASE("TRAP::Utils::RotatePixelData90Clockwise()", "[utils][imageutils]")
{
STATIC_REQUIRE(CheckRotate90Clockwise<f32>(32u, 32u, 3u, TestImageHDRPixelDataRGB, TestImageHDRPixelDataRGBRotated90Clockwise));
}

SECTION("Invalid")
{
STATIC_REQUIRE(TRAP::Utils::RotatePixelData90Clockwise<u8>(0u, 2u, 4u, {}).empty());
STATIC_REQUIRE(TRAP::Utils::RotatePixelData90Clockwise<u8>(2u, 0u, 4u, {}).empty());
STATIC_REQUIRE(TRAP::Utils::RotatePixelData90Clockwise<u8>(2u, 2u, 0u, {}).empty());

STATIC_REQUIRE(TRAP::Utils::RotatePixelData90Clockwise<u8>(2u, 2u, 100u, {}).empty());

STATIC_REQUIRE(TRAP::Utils::RotatePixelData90Clockwise<u8>(2u, 2u, 4u, {}).empty());
}
}

TEST_CASE("TRAP::Utils::RotatePixelData90CounterClockwise()", "[utils][imageutils]")
Expand Down Expand Up @@ -304,6 +337,17 @@ TEST_CASE("TRAP::Utils::RotatePixelData90CounterClockwise()", "[utils][imageutil
{
STATIC_REQUIRE(CheckRotate90CounterClockwise<f32>(32u, 32u, 3u, TestImageHDRPixelDataRGB, TestImageHDRPixelDataRGBRotated90CounterClockwise));
}

SECTION("Invalid")
{
STATIC_REQUIRE(TRAP::Utils::RotatePixelData90CounterClockwise<u8>(0u, 2u, 4u, {}).empty());
STATIC_REQUIRE(TRAP::Utils::RotatePixelData90CounterClockwise<u8>(2u, 0u, 4u, {}).empty());
STATIC_REQUIRE(TRAP::Utils::RotatePixelData90CounterClockwise<u8>(2u, 2u, 0u, {}).empty());

STATIC_REQUIRE(TRAP::Utils::RotatePixelData90CounterClockwise<u8>(2u, 2u, 100u, {}).empty());

STATIC_REQUIRE(TRAP::Utils::RotatePixelData90CounterClockwise<u8>(2u, 2u, 4u, {}).empty());
}
}

TEST_CASE("TRAP::Utils::ConvertRGBPixelDataToRGBA()", "[utils][imageutils]")
Expand All @@ -322,6 +366,17 @@ TEST_CASE("TRAP::Utils::ConvertRGBPixelDataToRGBA()", "[utils][imageutils]")
{
STATIC_REQUIRE(CheckRGBToRGBA<u16>(32u, 32u, TestImageSDR16PixelDataRGB, TestImageSDR16PixelDataRGBA));
}

SECTION("HDR RGB (f32)")
{
STATIC_REQUIRE(CheckRGBToRGBA<f32>(32u, 32u, TestImageHDRPixelDataRGB, TestImageHDRPixelDataRGBA));
}

SECTION("Invalid")
{
STATIC_REQUIRE(TRAP::Utils::ConvertRGBPixelDataToRGBA<u8>(0u, 2u, {}).empty());
STATIC_REQUIRE(TRAP::Utils::ConvertRGBPixelDataToRGBA<u8>(2u, 0u, {}).empty());
}
}

TEST_CASE("TRAP::Utils::ConvertRGBAPixelDataToRGB()", "[utils][imageutils]")
Expand All @@ -340,4 +395,82 @@ TEST_CASE("TRAP::Utils::ConvertRGBAPixelDataToRGB()", "[utils][imageutils]")
{
STATIC_REQUIRE(CheckRGBAToRGB<u16>(32u, 32u, TestImageSDR16PixelDataRGBA, TestImageSDR16PixelDataRGB));
}

SECTION("HDR RGBA (f32)")
{
STATIC_REQUIRE(CheckRGBAToRGB<f32>(32u, 32u, TestImageHDRPixelDataRGBA, TestImageHDRPixelDataRGB));
}

SECTION("Invalid")
{
STATIC_REQUIRE(TRAP::Utils::ConvertRGBAPixelDataToRGB<u8>(0u, 2u, {}).empty());
STATIC_REQUIRE(TRAP::Utils::ConvertRGBAPixelDataToRGB<u8>(2u, 0u, {}).empty());
}
}

TEST_CASE("TRAP::Utils::ConvertBGR16PixelDataToRGB24()", "[utils][imageutils]")
{
SECTION("Valid")
{
STATIC_REQUIRE(std::ranges::equal(TRAP::Utils::ConvertBGR16PixelDataToRGB24(TestImageSDRPixelDataBGR16, 32u, 32u), TestImageSDRPixelDataRGB_BGR16));
}

SECTION("Invalid")
{
STATIC_REQUIRE(TRAP::Utils::ConvertBGR16PixelDataToRGB24({}, 0u, 32u).empty());
STATIC_REQUIRE(TRAP::Utils::ConvertBGR16PixelDataToRGB24({}, 32u, 0u).empty());

STATIC_REQUIRE(TRAP::Utils::ConvertBGR16PixelDataToRGB24({}, 32u, 32u).empty());
}
}

TEST_CASE("TRAP::Utils::ConvertBGR24PixelDataToRGB24()", "[utils][imageutils]")
{
SECTION("Valid")
{
STATIC_REQUIRE(std::ranges::equal(TRAP::Utils::ConvertBGR24PixelDataToRGB24(TestImageSDRPixelDataBGR, 32u, 32u), TestImageSDRPixelDataRGB));
}

SECTION("Invalid")
{
STATIC_REQUIRE(TRAP::Utils::ConvertBGR24PixelDataToRGB24({}, 0u, 32u).empty());
STATIC_REQUIRE(TRAP::Utils::ConvertBGR24PixelDataToRGB24({}, 32u, 0u).empty());

STATIC_REQUIRE(TRAP::Utils::ConvertBGR24PixelDataToRGB24({}, 32u, 32u).empty());
}
}

TEST_CASE("TRAP::Utils::ConvertBGRA32PixelDataToRGBA32()", "[utils][imageutils]")
{
SECTION("Valid")
{
STATIC_REQUIRE(std::ranges::equal(TRAP::Utils::ConvertBGRA32PixelDataToRGBA32(TestImageSDRPixelDataBGRA, 32u, 32u), TestImageSDRPixelDataRGBA));
}

SECTION("Invalid")
{
STATIC_REQUIRE(TRAP::Utils::ConvertBGRA32PixelDataToRGBA32({}, 0u, 32u).empty());
STATIC_REQUIRE(TRAP::Utils::ConvertBGRA32PixelDataToRGBA32({}, 32u, 0u).empty());

STATIC_REQUIRE(TRAP::Utils::ConvertBGRA32PixelDataToRGBA32({}, 32u, 32u).empty());
}
}

TEST_CASE("TRAP::Utils::DecodeBGRAMappedPixelData()", "[utils][imageutils]")
{
SECTION("Valid")
{
STATIC_REQUIRE(std::ranges::equal(TRAP::Utils::DecodeBGRAMappedPixelData(TestImageSDRMappedBGRA, 32u, 32u, 4u, TestImageSDRColorMapBGRA), TestImageSDRPixelDataRGBA));
STATIC_REQUIRE(std::ranges::equal(TRAP::Utils::FlipPixelDataY<u8>(32u, 32u, 3u, TRAP::Utils::DecodeBGRAMappedPixelData(TestImageSDRMappedBGR, 32u, 32u, 3u, TestImageSDRColorMapBGR)), TestImageSDRPixelDataRGB));
}

SECTION("Invalid")
{
STATIC_REQUIRE(TRAP::Utils::DecodeBGRAMappedPixelData({}, 0u, 32u, 4u, TestImageSDRColorMapBGRA).empty());
STATIC_REQUIRE(TRAP::Utils::DecodeBGRAMappedPixelData({}, 32u, 0u, 4u, TestImageSDRColorMapBGRA).empty());
STATIC_REQUIRE(TRAP::Utils::DecodeBGRAMappedPixelData({}, 32u, 32u, 0u, TestImageSDRColorMapBGRA).empty());
STATIC_REQUIRE(TRAP::Utils::DecodeBGRAMappedPixelData({}, 32u, 32u, 4u, {}).empty());
STATIC_REQUIRE(TRAP::Utils::DecodeBGRAMappedPixelData({}, 32u, 32u, 100u, TestImageSDRColorMapBGRA).empty());
STATIC_REQUIRE(TRAP::Utils::DecodeBGRAMappedPixelData({}, 32u, 32u, 4u, TestImageSDRColorMapBGRA).empty());
}
}

0 comments on commit 03d1534

Please sign in to comment.