Add unit tests for Photoshop::isIrb().
It has been detected that we need to always pass the size==4 in the call to isIrb. Probably it is better to remove that parameter and document that it is assumed for the buffer to have a length of 4 bytes.
This commit is contained in:
parent
a698c3fc08
commit
7366a64d44
@ -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
|
||||
|
||||
31
unitTests/test_Photoshop.cpp
Normal file
31
unitTests/test_Photoshop.cpp
Normal file
@ -0,0 +1,31 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include <exiv2/jpgimage.hpp>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
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<const byte*>(marker), 4));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
TEST(Photoshop_isIrb, returnsFalseWithInvalidMarkers) {
|
||||
ASSERT_FALSE(Photoshop::isIrb(reinterpret_cast<const byte *>("7BIM"), 4));
|
||||
ASSERT_FALSE(Photoshop::isIrb(reinterpret_cast<const byte *>("AGHg"), 4));
|
||||
ASSERT_FALSE(Photoshop::isIrb(reinterpret_cast<const byte *>("dcsr"), 4));
|
||||
ASSERT_FALSE(Photoshop::isIrb(reinterpret_cast<const byte *>("LUIS"), 4));
|
||||
}
|
||||
|
||||
TEST(Photoshop_isIrb, returnsFalseWithInvalidSize) {
|
||||
ASSERT_FALSE(Photoshop::isIrb(reinterpret_cast<const byte *>("8BIM"), 3));
|
||||
ASSERT_FALSE(Photoshop::isIrb(reinterpret_cast<const byte *>("8BIM"), 0));
|
||||
ASSERT_FALSE(Photoshop::isIrb(reinterpret_cast<const byte *>("8BIM"), 5));
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user