diff --git a/unitTests/CMakeLists.txt b/unitTests/CMakeLists.txt index 4a766429..c6db700d 100644 --- a/unitTests/CMakeLists.txt +++ b/unitTests/CMakeLists.txt @@ -18,6 +18,7 @@ add_executable(unit_tests test_jp2image_int.cpp test_IptcKey.cpp test_LangAltValueRead.cpp + test_Photoshop.cpp test_pngimage.cpp test_safe_op.cpp test_slice.cpp diff --git a/unitTests/test_Photoshop.cpp b/unitTests/test_Photoshop.cpp new file mode 100644 index 00000000..c38a14dc --- /dev/null +++ b/unitTests/test_Photoshop.cpp @@ -0,0 +1,31 @@ +// SPDX-License-Identifier: GPL-2.0-or-later + +#include + +#include + +using namespace Exiv2; + +namespace { +constexpr std::array validMarkers{"8BIM", "AgHg", "DCSR", "PHUT"}; +} + +TEST(Photoshop_isIrb, returnsTrueWithValidMarkers) { + for (const auto& marker : validMarkers) { + ASSERT_TRUE(Photoshop::isIrb(reinterpret_cast(marker), 4)); + } +} + + +TEST(Photoshop_isIrb, returnsFalseWithInvalidMarkers) { + ASSERT_FALSE(Photoshop::isIrb(reinterpret_cast("7BIM"), 4)); + ASSERT_FALSE(Photoshop::isIrb(reinterpret_cast("AGHg"), 4)); + ASSERT_FALSE(Photoshop::isIrb(reinterpret_cast("dcsr"), 4)); + ASSERT_FALSE(Photoshop::isIrb(reinterpret_cast("LUIS"), 4)); +} + +TEST(Photoshop_isIrb, returnsFalseWithInvalidSize) { + ASSERT_FALSE(Photoshop::isIrb(reinterpret_cast("8BIM"), 3)); + ASSERT_FALSE(Photoshop::isIrb(reinterpret_cast("8BIM"), 0)); + ASSERT_FALSE(Photoshop::isIrb(reinterpret_cast("8BIM"), 5)); +}