Added implementation of Rotation methods, and tests
This commit is contained in:
@@ -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
54
Test/Rotate.cpp
Normal 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;
|
||||
}
|
BIN
Test/TestAssets/base_mateya.bmp
Normal file
BIN
Test/TestAssets/base_mateya.bmp
Normal file
Binary file not shown.
After Width: | Height: | Size: 348 KiB |
BIN
Test/TestAssets/base_mateya_rot_180deg.bmp
Normal file
BIN
Test/TestAssets/base_mateya_rot_180deg.bmp
Normal file
Binary file not shown.
After Width: | Height: | Size: 348 KiB |
BIN
Test/TestAssets/base_mateya_rot_270deg.bmp
Normal file
BIN
Test/TestAssets/base_mateya_rot_270deg.bmp
Normal file
Binary file not shown.
After Width: | Height: | Size: 348 KiB |
BIN
Test/TestAssets/base_mateya_rot_90deg.bmp
Normal file
BIN
Test/TestAssets/base_mateya_rot_90deg.bmp
Normal file
Binary file not shown.
After Width: | Height: | Size: 348 KiB |
Reference in New Issue
Block a user