Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
siers committed Dec 18, 2024
1 parent 2991e89 commit e02685a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
Binary file added test/_test_data/images/unit/jpegCorrupt.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 13 additions & 2 deletions test/unit/sipiimage/sipiimage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "gtest/gtest.h"

#include "../../../src/SipiImage.hpp"
#include "../../../src/SipiImageError.hpp"
#include "SipiIOTiff.h"

// small function to check if file exist
Expand Down Expand Up @@ -39,6 +40,7 @@ const std::string wrongrotation = "../../../../test/_test_data/images/unit/image
const std::string watermark_correct = "../../../../test/_test_data/images/unit/watermark_correct.tif";
const std::string watermark_incorrect = "../../../../test/_test_data/images/unit/watermark_incorrect.tif";
const std::string tiffJpegScanlineBug = "../../../../test/_test_data/images/knora/tiffJpegScanlineBug.tif";
const std::string jpegCorrupt = "../../../../test/_test_data/images/unit/jpegCorrupt.jpg";

// Check if configuration file can be found
TEST(SipiImage, CheckIfTestImagesCanBeFound)
Expand Down Expand Up @@ -329,10 +331,10 @@ TEST(SipiImage, Watermark)
/* ASSERT_NO_THROW(img3.write("jpg", maoriWater)); */

ASSERT_NO_THROW(img4.read(maoriWater));
EXPECT_TRUE(img4.compare(img3).value_or(1000) < 0.007); // 0.00605
EXPECT_TRUE(img4.compare(img3).value_or(1000) < 0.007);// 0.00605

ASSERT_NO_THROW(img3.read(maori));
EXPECT_TRUE(img4.compare(img3) > 0.017); // 0.0174
EXPECT_TRUE(img4.compare(img3) > 0.017);// 0.0174

ASSERT_NO_THROW(img3.rotate(90));
}
Expand Down Expand Up @@ -378,3 +380,12 @@ TEST(SipiImage, TiffJpegAutoRgbConvert)
EXPECT_NO_THROW(img.read(tiffJpegScanlineBug));
EXPECT_NO_THROW(img.write("jpx", "../../../../test/_test_data/images/thumbs/tiffJpegScanlineBug.jp2"));
}

// Expect a crash when libjpeg reports a JWRN_HIT_MARKER.
TEST(SipiImage, JpegCorruptWarn)
{
Sipi::SipiIOTiff::initLibrary();
Sipi::SipiImage img;

EXPECT_THROW(img.read(jpegCorrupt), Sipi::SipiImageError);
}

0 comments on commit e02685a

Please sign in to comment.