Added tests for mirroring functions

This commit is contained in:
Leonetienne 2022-03-06 13:46:03 +01:00
parent fdc5d6f23f
commit 6534569840
8 changed files with 84 additions and 4 deletions

View File

@ -23,12 +23,12 @@ int main() {
bmp.Write("write.bmp");
*/
BMP bmp("test.bmp");
BMP bmp("basea_gradient.bmp");
//BMP newBmp = bmp.MirrorHorizontally();
BMP newBmp = bmp.MirrorVertically();
BMP newBmp = bmp.MirrorHorizontally();
//BMP newBmp = bmp.MirrorVertically();
if(!newBmp.Write("testwrite.bmp"))
if(!newBmp.Write("basea_gradient_flipped_hor.bmp"))
std::cerr << "What the hell" << std::endl;
/*

View File

@ -25,6 +25,8 @@ add_executable(Test
Write.cpp
OperatorEquals.cpp
FillChannel.cpp
MirrorHorizontally.cpp
MirrorVertically.cpp
)
# Move test images to build dir

View File

@ -0,0 +1,39 @@
#include <Bmp.h>
#include <stdexcept>
#include "Catch2.h"
using namespace Leonetienne::BmpPP;
using namespace Eule;
// Tests the mirror horizontal function against reference images
TEST_CASE(__FILE__"/Mirroring produces the correct results", "[Mirroring][MirrorHorizontally]")
{
SECTION("RGB") {
// Read a gradient image
BMP bmp("base_gradient.bmp");
// Mirror it
bmp = bmp.MirrorHorizontally();
// Read reference image
const BMP reference("base_gradient_flipped_hor.bmp");
// Assert that they are equal
REQUIRE(bmp == reference);
}
SECTION("RGBA") {
// Read a gradient image
BMP bmp("basea_gradient.bmp");
// Mirror it
bmp = bmp.MirrorHorizontally();
// Read reference image
const BMP reference("basea_gradient_flipped_hor.bmp");
// Assert that they are equal
REQUIRE(bmp == reference);
}
return;
}

39
Test/MirrorVertically.cpp Normal file
View File

@ -0,0 +1,39 @@
#include <Bmp.h>
#include <stdexcept>
#include "Catch2.h"
using namespace Leonetienne::BmpPP;
using namespace Eule;
// Tests the mirror vertical function against reference images
TEST_CASE(__FILE__"/Mirroring produces the correct results", "[Mirroring][MirrorVertically]")
{
SECTION("RGB") {
// Read a gradient image
BMP bmp("base_gradient.bmp");
// Mirror it
bmp = bmp.MirrorVertically();
// Read reference image
const BMP reference("base_gradient_flipped_ver.bmp");
// Assert that they are equal
REQUIRE(bmp == reference);
}
SECTION("RGBA") {
// Read a gradient image
BMP bmp("basea_gradient.bmp");
// Mirror it
bmp = bmp.MirrorVertically();
// Read reference image
const BMP reference("basea_gradient_flipped_ver.bmp");
// Assert that they are equal
REQUIRE(bmp == reference);
}
return;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 MiB