Skip to content

Commit

Permalink
Merge pull request #179 from UIUCLibrary/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
henryborchers authored Oct 26, 2023
2 parents 277563a + b3df9d3 commit 7044849
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -1241,7 +1241,7 @@ pipeline {
steps{
catchError(buildResult: 'SUCCESS', message: 'cppcheck found issues', stageResult: 'UNSTABLE') {
sh(label: 'Running cppcheck',
script: 'cppcheck --error-exitcode=1 --project=build/cpp/compile_commands.json -i$WORKSPACE/build/cpp/_deps --suppress=*:$WORKSPACE/build/cpp/_deps/* --enable=all --xml --output-file=logs/cppcheck_debug.xml'
script: 'cppcheck --error-exitcode=1 --project=build/cpp/compile_commands.json -i$WORKSPACE/build/cpp/_deps --suppress=*:build/cpp/_deps/* --enable=all --xml --output-file=logs/cppcheck_debug.xml'
)
}
}
Expand Down
2 changes: 1 addition & 1 deletion ci/docker/linux/jenkins/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ARG PIP_FIND_LINKS=/wheels/
ARG CONAN_USER_HOME=/conan
ARG SONAR_SCANNER_VERSION=4.7.0.2747
ARG SONAR_SCANNER_VERSION=5.0.1.3006
ARG PYTHON_VERSION=3.11

FROM python:${PYTHON_VERSION} AS base_image
Expand Down
3 changes: 2 additions & 1 deletion tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ if (BUILD_TESTING)
$<TARGET_OBJECTS:glue>
# test_metadata_processor.cpp
# test_editing.cpp
test_make_dictionary.cpp)
test_make_dictionary.cpp
test-core.cpp)
target_compile_definitions(cpp_tests PRIVATE TEST_IMAGE_PATH="${TEST_IMAGE_PATH}")
set_target_properties(cpp_tests PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}
Expand Down
32 changes: 32 additions & 0 deletions tests/test-core.cpp
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);
}

0 comments on commit 7044849

Please sign in to comment.