Added implementation of Rotation methods, and tests

This commit is contained in:
Leonetienne
2022-03-06 14:51:01 +01:00
parent 046a694dc4
commit 316ddc4a24
7 changed files with 142 additions and 0 deletions

View File

@@ -28,6 +28,7 @@ add_executable(Test
MirrorHorizontally.cpp
MirrorVertically.cpp
SwapChannels.cpp
Rotate.cpp
)
# Move test images to build dir

54
Test/Rotate.cpp Normal file
View File

@@ -0,0 +1,54 @@
#include <Bmp.h>
#include <stdexcept>
#include "Catch2.h"
using namespace Leonetienne::BmpPP;
using namespace Eule;
// Tests that rotating works
TEST_CASE(__FILE__"/Mirroring produces the correct results", "[Rotate]")
{
SECTION("90deg clockwise") {
// Read an image
BMP bmp("base_mateya.bmp");
// Rotate it
bmp = bmp.Rotate90degClockwise();
// Read reference image
const BMP reference("base_mateya_rot_90deg.bmp");
// Assert that they are equal
REQUIRE(bmp == reference);
}
SECTION("90deg counterclockwise") {
// Read an image
BMP bmp("base_mateya.bmp");
// Rotate it
bmp = bmp.Rotate90degCounterclockwise();
// Read reference image
const BMP reference("base_mateya_rot_270deg.bmp");
// Assert that they are equal
REQUIRE(bmp == reference);
}
SECTION("180deg") {
// Read an image
BMP bmp("base_mateya.bmp");
// Rotate it
bmp = bmp.Rotate180deg();
// Read reference image
const BMP reference("base_mateya_rot_180deg.bmp");
// Assert that they are equal
REQUIRE(bmp == reference);
}
return;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 348 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 348 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 348 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 348 KiB