Skip to content

Commit

Permalink
Add test for editing dpi on empty file
Browse files Browse the repository at this point in the history
  • Loading branch information
henryborchers committed Oct 26, 2023
1 parent 6fbb644 commit 9050d45
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions tests/test-core.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#include <filesystem>
#include <iostream>
#include <fstream>
#include <string>
#include <catch2/catch.hpp>
#include "glue/glue.h"
Expand Down Expand Up @@ -27,10 +29,17 @@ TEST_CASE("TIFF files can edit their dpi"){
fs::remove(test_file);
}

TEST_CASE("invalid file with set_dpi raises"){
const std::string no_such_file = IMAGE_TEST_PATH + "invalid_file.tif";
TEST_CASE("missing file with set_dpi raises"){
const std::string no_such_file = IMAGE_TEST_PATH + "missing.tif";
REQUIRE_THROWS_AS(set_dpi(no_such_file, 100, 100), Exiv2::Error);
}
TEST_CASE("empty file with set_dpi raises"){
const std::string bad_file = IMAGE_TEST_PATH + "empty.tif";
std::ofstream invalidFile;
invalidFile.open(bad_file);
invalidFile.close();
REQUIRE_THROWS_AS(set_dpi(bad_file, 100, 100), Exiv2::Error);
}

TEST_CASE("exiv2_version uses a semantic versioning scheme"){
REQUIRE(std::regex_match(exiv2_version(), std::regex("^([0-9]+)\\.([0-9]+)\\.([0-9]+)$")));
Expand Down

0 comments on commit 9050d45

Please sign in to comment.