Added tests for mirroring functions
This commit is contained in:
parent
fdc5d6f23f
commit
6534569840
@ -23,12 +23,12 @@ int main() {
|
|||||||
bmp.Write("write.bmp");
|
bmp.Write("write.bmp");
|
||||||
*/
|
*/
|
||||||
|
|
||||||
BMP bmp("test.bmp");
|
BMP bmp("basea_gradient.bmp");
|
||||||
|
|
||||||
//BMP newBmp = bmp.MirrorHorizontally();
|
BMP newBmp = bmp.MirrorHorizontally();
|
||||||
BMP newBmp = bmp.MirrorVertically();
|
//BMP newBmp = bmp.MirrorVertically();
|
||||||
|
|
||||||
if(!newBmp.Write("testwrite.bmp"))
|
if(!newBmp.Write("basea_gradient_flipped_hor.bmp"))
|
||||||
std::cerr << "What the hell" << std::endl;
|
std::cerr << "What the hell" << std::endl;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -25,6 +25,8 @@ add_executable(Test
|
|||||||
Write.cpp
|
Write.cpp
|
||||||
OperatorEquals.cpp
|
OperatorEquals.cpp
|
||||||
FillChannel.cpp
|
FillChannel.cpp
|
||||||
|
MirrorHorizontally.cpp
|
||||||
|
MirrorVertically.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
# Move test images to build dir
|
# Move test images to build dir
|
||||||
|
39
Test/MirrorHorizontally.cpp
Normal file
39
Test/MirrorHorizontally.cpp
Normal 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
39
Test/MirrorVertically.cpp
Normal 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;
|
||||||
|
}
|
BIN
Test/TestAssets/base_gradient_flipped_hor.bmp
Normal file
BIN
Test/TestAssets/base_gradient_flipped_hor.bmp
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.4 MiB |
BIN
Test/TestAssets/base_gradient_flipped_ver.bmp
Normal file
BIN
Test/TestAssets/base_gradient_flipped_ver.bmp
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.4 MiB |
BIN
Test/TestAssets/basea_gradient_flipped_hor.bmp
Normal file
BIN
Test/TestAssets/basea_gradient_flipped_hor.bmp
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.8 MiB |
BIN
Test/TestAssets/basea_gradient_flipped_ver.bmp
Normal file
BIN
Test/TestAssets/basea_gradient_flipped_ver.bmp
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.8 MiB |
Loading…
x
Reference in New Issue
Block a user