Improve wxImage::ChangeColours test code
Use a helper function to both make it shorter and provide more information in case of a check failure: now the output will include the name of the file, comparing with which failed, allowing to immediately see which test failed.
This commit is contained in:
parent
f77390551f
commit
2ed4e6bee4
1 changed files with 23 additions and 16 deletions
|
|
@ -2276,6 +2276,21 @@ TEST_CASE("wxImage::PNM", "[image][pnm]")
|
|||
#endif
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
inline ImageRGBMatcher RGBSimilarToFile(const char* name)
|
||||
{
|
||||
INFO("Loading file from " << name);
|
||||
|
||||
wxImage expected;
|
||||
REQUIRE(expected.LoadFile(name));
|
||||
|
||||
return ImageRGBMatcher(expected, 1);
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
TEST_CASE("wxImage::ChangeColours", "[image]")
|
||||
{
|
||||
wxImage original;
|
||||
|
|
@ -2286,43 +2301,35 @@ TEST_CASE("wxImage::ChangeColours", "[image]")
|
|||
|
||||
test = original;
|
||||
test.RotateHue(0.538);
|
||||
REQUIRE(expected.LoadFile("image/toucan_hue_0.538.png", wxBITMAP_TYPE_PNG));
|
||||
CHECK_THAT(test, RGBSimilarTo(expected, 1));
|
||||
CHECK_THAT(test, RGBSimilarToFile("image/toucan_hue_0.538.png"));
|
||||
|
||||
test = original;
|
||||
test.ChangeSaturation(-0.41);
|
||||
REQUIRE(expected.LoadFile("image/toucan_sat_-0.41.png", wxBITMAP_TYPE_PNG));
|
||||
CHECK_THAT(test, RGBSimilarTo(expected, 1));
|
||||
CHECK_THAT(test, RGBSimilarToFile("image/toucan_sat_-0.41.png"));
|
||||
|
||||
test = original;
|
||||
test.ChangeBrightness(-0.259);
|
||||
REQUIRE(expected.LoadFile("image/toucan_bright_-0.259.png", wxBITMAP_TYPE_PNG));
|
||||
CHECK_THAT(test, RGBSimilarTo(expected, 1));
|
||||
CHECK_THAT(test, RGBSimilarToFile("image/toucan_bright_-0.259.png"));
|
||||
|
||||
test = original;
|
||||
test.ChangeHSV(0.538, -0.41, -0.259);
|
||||
REQUIRE(expected.LoadFile("image/toucan_hsv_0.538_-0.41_-0.259.png", wxBITMAP_TYPE_PNG));
|
||||
CHECK_THAT(test, RGBSimilarTo(expected, 1));
|
||||
CHECK_THAT(test, RGBSimilarToFile("image/toucan_hsv_0.538_-0.41_-0.259.png"));
|
||||
|
||||
test = original;
|
||||
test = test.ChangeLightness(46);
|
||||
REQUIRE(expected.LoadFile("image/toucan_light_46.png", wxBITMAP_TYPE_PNG));
|
||||
CHECK_THAT(test, RGBSimilarTo(expected, 1));
|
||||
CHECK_THAT(test, RGBSimilarToFile("image/toucan_light_46.png"));
|
||||
|
||||
test = original;
|
||||
test = test.ConvertToDisabled(240);
|
||||
REQUIRE(expected.LoadFile("image/toucan_dis_240.png", wxBITMAP_TYPE_PNG));
|
||||
CHECK_THAT(test, RGBSimilarTo(expected, 1));
|
||||
CHECK_THAT(test, RGBSimilarToFile("image/toucan_dis_240.png"));
|
||||
|
||||
test = original;
|
||||
test = test.ConvertToGreyscale();
|
||||
REQUIRE(expected.LoadFile("image/toucan_grey.png", wxBITMAP_TYPE_PNG));
|
||||
CHECK_THAT(test, RGBSimilarTo(expected, 1));
|
||||
CHECK_THAT(test, RGBSimilarToFile("image/toucan_grey.png"));
|
||||
|
||||
test = original;
|
||||
test = test.ConvertToMono(255, 255, 255);
|
||||
REQUIRE(expected.LoadFile("image/toucan_mono_255_255_255.png", wxBITMAP_TYPE_PNG));
|
||||
CHECK_THAT(test, RGBSimilarTo(expected, 1));
|
||||
CHECK_THAT(test, RGBSimilarToFile("image/toucan_mono_255_255_255.png"));
|
||||
}
|
||||
|
||||
TEST_CASE("wxImage::SizeLimits", "[image]")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue