-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #179 from UIUCLibrary/dev
Dev
- Loading branch information
Showing
4 changed files
with
36 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#include <filesystem> | ||
#include <string> | ||
#include <catch2/catch.hpp> | ||
#include "glue/glue.h" | ||
#include "glue/Image.h" | ||
|
||
const std::string IMAGE_TEST_PATH(TEST_IMAGE_PATH); | ||
|
||
namespace fs = std::filesystem; | ||
TEST_CASE("TIFF files can edit their dpi"){ | ||
const std::string source = IMAGE_TEST_PATH + "dummy.tif"; | ||
const std::string test_file = IMAGE_TEST_PATH + "current.tif"; | ||
SECTION("Copy test file"){ | ||
fs::copy(source, test_file); | ||
SECTION("Edit DPI"){ | ||
auto new_dpi_x_value = GENERATE(100, 200, 400); | ||
auto new_dpi_y_value = GENERATE(100, 200, 400); | ||
DYNAMIC_SECTION("Set DPI to " << new_dpi_x_value << " dots per inch x and " << new_dpi_y_value << " dots per inch y"){ | ||
set_dpi(test_file, new_dpi_x_value, new_dpi_y_value); | ||
const Image image(test_file); | ||
REQUIRE(image.get_exif_metadata()["Exif.Image.XResolution"] == std::to_string(new_dpi_x_value) + "/1"); | ||
REQUIRE(image.get_exif_metadata()["Exif.Image.YResolution"] == std::to_string(new_dpi_y_value) + "/1"); | ||
} | ||
} | ||
} | ||
fs::remove(test_file); | ||
} | ||
|
||
TEST_CASE("invalid file with set_dpi raises"){ | ||
const std::string no_such_file = IMAGE_TEST_PATH + "invalid_file.tif"; | ||
REQUIRE_THROWS_AS(set_dpi(no_such_file, 100, 100), Exiv2::Error); | ||
} |