exiv2/unitTests/test_Photoshop.cpp
Luis Diaz 7366a64d44 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.
2022-04-06 15:18:43 +02:00

32 lines
1.0 KiB
C++

// 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));
}