clang-tidy: no _ in tests

Found with google-readability-avoid-underscore-in-googletest-name

Signed-off-by: Rosen Penev <rosenp@gmail.com>
main
Rosen Penev 2 years ago
parent e854d93841
commit a3baf7d3e9

@ -13,29 +13,29 @@ namespace {
constexpr std::array validMarkers{"8BIM", "AgHg", "DCSR", "PHUT"}; constexpr std::array validMarkers{"8BIM", "AgHg", "DCSR", "PHUT"};
} // namespace } // namespace
TEST(Photoshop_isIrb, returnsTrueWithValidMarkers) { TEST(PhotoshopIsIrb, returnsTrueWithValidMarkers) {
for (const auto& marker : validMarkers) { for (const auto& marker : validMarkers) {
ASSERT_TRUE(Photoshop::isIrb(reinterpret_cast<const byte*>(marker))); ASSERT_TRUE(Photoshop::isIrb(reinterpret_cast<const byte*>(marker)));
} }
} }
TEST(Photoshop_isIrb, returnsFalseWithInvalidMarkers) { TEST(PhotoshopIsIrb, returnsFalseWithInvalidMarkers) {
ASSERT_FALSE(Photoshop::isIrb(reinterpret_cast<const byte*>("7BIM"))); ASSERT_FALSE(Photoshop::isIrb(reinterpret_cast<const byte*>("7BIM")));
ASSERT_FALSE(Photoshop::isIrb(reinterpret_cast<const byte*>("AGHg"))); ASSERT_FALSE(Photoshop::isIrb(reinterpret_cast<const byte*>("AGHg")));
ASSERT_FALSE(Photoshop::isIrb(reinterpret_cast<const byte*>("dcsr"))); ASSERT_FALSE(Photoshop::isIrb(reinterpret_cast<const byte*>("dcsr")));
ASSERT_FALSE(Photoshop::isIrb(reinterpret_cast<const byte*>("LUIS"))); ASSERT_FALSE(Photoshop::isIrb(reinterpret_cast<const byte*>("LUIS")));
} }
TEST(Photoshop_isIrb, returnsFalseWithNullPointer) { TEST(PhotoshopIsIrb, returnsFalseWithNullPointer) {
ASSERT_FALSE(Photoshop::isIrb(nullptr)); ASSERT_FALSE(Photoshop::isIrb(nullptr));
} }
/// \note probably this is not safe and we need to remove it /// \note probably this is not safe and we need to remove it
TEST(Photoshop_isIrb, returnsFalseWithShorterMarker) { TEST(PhotoshopIsIrb, returnsFalseWithShorterMarker) {
ASSERT_FALSE(Photoshop::isIrb(reinterpret_cast<const byte*>("8BI"))); ASSERT_FALSE(Photoshop::isIrb(reinterpret_cast<const byte*>("8BI")));
} }
TEST(Photoshop_locateIrb, returnsMinus2withInvalidPhotoshopIRB) { TEST(PhotoshopLocateIrb, returnsMinus2withInvalidPhotoshopIRB) {
const std::string data{"8BIMlalalalalalala"}; const std::string data{"8BIMlalalalalalala"};
const Exiv2::byte* record; const Exiv2::byte* record;
uint32_t sizeHdr = 0; uint32_t sizeHdr = 0;
@ -44,7 +44,7 @@ TEST(Photoshop_locateIrb, returnsMinus2withInvalidPhotoshopIRB) {
&record, sizeHdr, sizeData)); &record, sizeHdr, sizeData));
} }
TEST(Photoshop_locateIrb, returnsMinus2WithMarkerNotStartingWith8BIM) { TEST(PhotoshopLocateIrb, returnsMinus2WithMarkerNotStartingWith8BIM) {
const std::string data{"7BIMlalalalalalalala"}; const std::string data{"7BIMlalalalalalalala"};
const Exiv2::byte* record; const Exiv2::byte* record;
uint32_t sizeHdr = 0; uint32_t sizeHdr = 0;
@ -53,7 +53,7 @@ TEST(Photoshop_locateIrb, returnsMinus2WithMarkerNotStartingWith8BIM) {
&record, sizeHdr, sizeData)); &record, sizeHdr, sizeData));
} }
TEST(Photoshop_locateIrb, returns3withNotLongEnoughData) { TEST(PhotoshopLocateIrb, returns3withNotLongEnoughData) {
const std::string data{"8BIMlala"}; const std::string data{"8BIMlala"};
const Exiv2::byte* record; const Exiv2::byte* record;
uint32_t sizeHdr = 0; uint32_t sizeHdr = 0;
@ -62,7 +62,7 @@ TEST(Photoshop_locateIrb, returns3withNotLongEnoughData) {
sizeHdr, sizeData)); sizeHdr, sizeData));
} }
TEST(Photoshop_locateIrb, returns0withGoodIptcIrb) { TEST(PhotoshopLocateIrb, returns0withGoodIptcIrb) {
// Data taken from file test/data/DSC_3079.jpg // Data taken from file test/data/DSC_3079.jpg
// The IPTC marker is 0x04 0x04 // The IPTC marker is 0x04 0x04
const std::array<byte, 68> data{0x38, 0x42, 0x49, 0x4d, 0x04, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1b, 0x1c, 0x01, const std::array<byte, 68> data{0x38, 0x42, 0x49, 0x4d, 0x04, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1b, 0x1c, 0x01,
@ -80,7 +80,7 @@ TEST(Photoshop_locateIrb, returns0withGoodIptcIrb) {
ASSERT_EQ(27, sizeData); ASSERT_EQ(27, sizeData);
} }
TEST(Photoshop_locateIptcIrb, returns0withGoodIptcIrb) { TEST(PhotoshopLocateIptcIrb, returns0withGoodIptcIrb) {
// Data taken from file test/data/DSC_3079.jpg // Data taken from file test/data/DSC_3079.jpg
// The IPTC marker is 0x04 0x04 // The IPTC marker is 0x04 0x04
const std::array<byte, 68> data{0x38, 0x42, 0x49, 0x4d, 0x04, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1b, 0x1c, 0x01, const std::array<byte, 68> data{0x38, 0x42, 0x49, 0x4d, 0x04, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1b, 0x1c, 0x01,
@ -98,7 +98,7 @@ TEST(Photoshop_locateIptcIrb, returns0withGoodIptcIrb) {
ASSERT_EQ(27, sizeData); ASSERT_EQ(27, sizeData);
} }
TEST(Photoshop_locateIptcIrb, returns3withoutIptcMarker) { TEST(PhotoshopLocateIptcIrb, returns3withoutIptcMarker) {
// Data taken from file test/data/DSC_3079.jpg // Data taken from file test/data/DSC_3079.jpg
// The IPTC marker (0x04 0x04) was manipulated to 0x03 0x04 // The IPTC marker (0x04 0x04) was manipulated to 0x03 0x04
const std::array<byte, 68> data{0x38, 0x42, 0x49, 0x4d, 0x03, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1b, 0x1c, 0x01, const std::array<byte, 68> data{0x38, 0x42, 0x49, 0x4d, 0x03, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1b, 0x1c, 0x01,
@ -114,7 +114,7 @@ TEST(Photoshop_locateIptcIrb, returns3withoutIptcMarker) {
ASSERT_EQ(3, Photoshop::locateIptcIrb(data.data(), data.size(), &record, sizeHdr, sizeData)); ASSERT_EQ(3, Photoshop::locateIptcIrb(data.data(), data.size(), &record, sizeHdr, sizeData));
} }
TEST(Photoshop_locatePreviewIrb, returns0withGoodPreviewIrb) { TEST(PhotoshopLocatePreviewIrb, returns0withGoodPreviewIrb) {
// Data taken from file test/data/DSC_3079.jpg // Data taken from file test/data/DSC_3079.jpg
// The IPTC marker is 0x04 0x04 was transformed to a Preview one => (0x04 0x0c) // The IPTC marker is 0x04 0x04 was transformed to a Preview one => (0x04 0x0c)
const std::array<byte, 68> data{0x38, 0x42, 0x49, 0x4d, 0x04, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1b, 0x1c, 0x01, const std::array<byte, 68> data{0x38, 0x42, 0x49, 0x4d, 0x04, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1b, 0x1c, 0x01,
@ -134,13 +134,13 @@ TEST(Photoshop_locatePreviewIrb, returns0withGoodPreviewIrb) {
// -------------------------------- // --------------------------------
TEST(Photoshop_setIptcIrb, withEmptyDataReturnsEmptyBuffer) { TEST(PhotoshopSetIptcIrb, withEmptyDataReturnsEmptyBuffer) {
const IptcData iptc; const IptcData iptc;
DataBuf buf = Photoshop::setIptcIrb(nullptr, 0, iptc); DataBuf buf = Photoshop::setIptcIrb(nullptr, 0, iptc);
ASSERT_TRUE(buf.empty()); ASSERT_TRUE(buf.empty());
} }
TEST(Photoshop_setIptcIrb, detectIntegerOverflow_withDataFromPOC2179) { TEST(PhotoshopSetIptcIrb, detectIntegerOverflowWithDataFromPOC2179) {
const std::array<byte, 141> data{ const std::array<byte, 141> data{
0x38, 0x42, 0x49, 0x4d, 0x20, 0x20, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x38, 0x42, 0x49, 0x4d, 0x04, 0x04, 0x38, 0x42, 0x49, 0x4d, 0x20, 0x20, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x38, 0x42, 0x49, 0x4d, 0x04, 0x04,
0x00, 0x20, 0x00, 0x00, 0x00, 0x75, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0xff, 0x20, 0x20, 0x00, 0x20, 0x00, 0x00, 0x00, 0x75, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0xff, 0x20, 0x20,
@ -156,7 +156,7 @@ TEST(Photoshop_setIptcIrb, detectIntegerOverflow_withDataFromPOC2179) {
ASSERT_THROW(Photoshop::setIptcIrb(data.data(), data.size(), iptc), Exiv2::Error); ASSERT_THROW(Photoshop::setIptcIrb(data.data(), data.size(), iptc), Exiv2::Error);
} }
TEST(Photoshop_setIptcIrb, returnsEmptyBufferWhenDataDoesNotHave8BIM) { TEST(PhotoshopSetIptcIrb, returnsEmptyBufferWhenDataDoesNotHave8BIM) {
// First byte replaced from 0x38 to 0x37 // First byte replaced from 0x38 to 0x37
const std::array<byte, 181> data{ const std::array<byte, 181> data{
0x37, 0x42, 0x49, 0x4d, 0x20, 0x20, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x38, 0x42, 0x49, 0x4d, 0x04, 0x04, 0x00, 0x37, 0x42, 0x49, 0x4d, 0x20, 0x20, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x38, 0x42, 0x49, 0x4d, 0x04, 0x04, 0x00,

@ -33,7 +33,7 @@ TEST(ATimeValue, canBeReadFromCompleteBasicFormatString) {
ASSERT_EQ(2, value.getTime().second); ASSERT_EQ(2, value.getTime().second);
} }
TEST(ATimeValue, canBeReadFromReducedBasicFormatString_HHMM) { TEST(ATimeValue, canBeReadFromReducedBasicFormatStringHHMM) {
TimeValue value; TimeValue value;
const std::string hms("2355"); const std::string hms("2355");
ASSERT_EQ(0, value.read(hms)); ASSERT_EQ(0, value.read(hms));
@ -42,7 +42,7 @@ TEST(ATimeValue, canBeReadFromReducedBasicFormatString_HHMM) {
ASSERT_EQ(0, value.getTime().second); ASSERT_EQ(0, value.getTime().second);
} }
TEST(ATimeValue, canBeReadFromReducedBasicFormatString_HH) { TEST(ATimeValue, canBeReadFromReducedBasicFormatStringHH) {
TimeValue value; TimeValue value;
const std::string hms("23"); const std::string hms("23");
ASSERT_EQ(0, value.read(hms)); ASSERT_EQ(0, value.read(hms));
@ -60,7 +60,7 @@ TEST(ATimeValue, canBeReadFromCompleteExtendedFormatString) {
ASSERT_EQ(2, value.getTime().second); ASSERT_EQ(2, value.getTime().second);
} }
TEST(ATimeValue, canBeReadFromReducedExtendedFormatString_HHMM) { TEST(ATimeValue, canBeReadFromReducedExtendedFormatStringHHMM) {
TimeValue value; TimeValue value;
const std::string hms("23:55"); const std::string hms("23:55");
ASSERT_EQ(0, value.read(hms)); ASSERT_EQ(0, value.read(hms));

@ -7,30 +7,30 @@
using namespace Exiv2; using namespace Exiv2;
TEST(MemIo_Default, readEReturns0) { TEST(MemIoDefault, readEReturns0) {
std::array<byte, 10> buf; std::array<byte, 10> buf;
MemIo io; MemIo io;
ASSERT_EQ(0, io.read(buf.data(), buf.size())); ASSERT_EQ(0, io.read(buf.data(), buf.size()));
} }
TEST(MemIo_Default, isNotAtEof) { TEST(MemIoDefault, isNotAtEof) {
MemIo io; MemIo io;
ASSERT_FALSE(io.eof()); ASSERT_FALSE(io.eof());
} }
TEST(MemIo_Default, seekBeyondBufferSizeReturns1AndSetsEofToTrue) { TEST(MemIoDefault, seekBeyondBufferSizeReturns1AndSetsEofToTrue) {
MemIo io; MemIo io;
ASSERT_EQ(1, io.seek(1, BasicIo::beg)); ASSERT_EQ(1, io.seek(1, BasicIo::beg));
ASSERT_TRUE(io.eof()); ASSERT_TRUE(io.eof());
} }
TEST(MemIo_Default, seekBefore0Returns1ButItDoesNotSetEofToTrue) { TEST(MemIoDefault, seekBefore0Returns1ButItDoesNotSetEofToTrue) {
MemIo io; MemIo io;
ASSERT_EQ(1, io.seek(-1, BasicIo::beg)); ASSERT_EQ(1, io.seek(-1, BasicIo::beg));
ASSERT_FALSE(io.eof()); ASSERT_FALSE(io.eof());
} }
TEST(MemIo_Default, seekToEndPosition_doesNotTriggerEof) { TEST(MemIoDefault, seekToEndPositionDoesNotTriggerEof) {
MemIo io; MemIo io;
ASSERT_EQ(0, io.tell()); ASSERT_EQ(0, io.tell());
ASSERT_EQ(0, io.seek(0, BasicIo::end)); ASSERT_EQ(0, io.seek(0, BasicIo::end));
@ -38,7 +38,7 @@ TEST(MemIo_Default, seekToEndPosition_doesNotTriggerEof) {
ASSERT_FALSE(io.eof()); ASSERT_FALSE(io.eof());
} }
TEST(MemIo_Default, seekToEndPositionAndReadTriggersEof) { TEST(MemIoDefault, seekToEndPositionAndReadTriggersEof) {
MemIo io; MemIo io;
ASSERT_EQ(0, io.seek(0, BasicIo::end)); ASSERT_EQ(0, io.seek(0, BasicIo::end));
ASSERT_EQ(0, io.tell()); ASSERT_EQ(0, io.tell());
@ -92,7 +92,7 @@ TEST(MemIo, seekInsideBoundsMoveThePosition) {
ASSERT_EQ(32, io.tell()); ASSERT_EQ(32, io.tell());
} }
TEST(MemIo, seekInsideBoundsUsingBeg_resetsThePosition) { TEST(MemIo, seekInsideBoundsUsingBegResetsThePosition) {
std::array<byte, 64> buf = {}; std::array<byte, 64> buf = {};
MemIo io(buf.data(), buf.size()); MemIo io(buf.data(), buf.size());
@ -103,7 +103,7 @@ TEST(MemIo, seekInsideBoundsUsingBeg_resetsThePosition) {
} }
} }
TEST(MemIo, seekInsideBoundsUsingCur_shiftThePosition) { TEST(MemIo, seekInsideBoundsUsingCurShiftThePosition) {
std::array<byte, 64> buf = {}; std::array<byte, 64> buf = {};
MemIo io(buf.data(), buf.size()); MemIo io(buf.data(), buf.size());
@ -115,7 +115,7 @@ TEST(MemIo, seekInsideBoundsUsingCur_shiftThePosition) {
} }
} }
TEST(MemIo, seekToEndPosition_doesNotTriggerEof) { TEST(MemIo, seekToEndPositionDoesNotTriggerEof) {
std::array<byte, 64> buf = {}; std::array<byte, 64> buf = {};
MemIo io(buf.data(), buf.size()); MemIo io(buf.data(), buf.size());

@ -12,7 +12,7 @@
using namespace Exiv2; using namespace Exiv2;
using ::testing::StartsWith; using ::testing::StartsWith;
TEST(IptcDataSets, dataSetName_returnsValidNamesWhenRequestingNumbersAvailableInEnvelopeRecord) { TEST(IptcDataSets, dataSetNameReturnsValidNamesWhenRequestingNumbersAvailableInEnvelopeRecord) {
ASSERT_EQ("ModelVersion", IptcDataSets::dataSetName(IptcDataSets::ModelVersion, IptcDataSets::envelope)); ASSERT_EQ("ModelVersion", IptcDataSets::dataSetName(IptcDataSets::ModelVersion, IptcDataSets::envelope));
ASSERT_EQ("Destination", IptcDataSets::dataSetName(IptcDataSets::Destination, IptcDataSets::envelope)); ASSERT_EQ("Destination", IptcDataSets::dataSetName(IptcDataSets::Destination, IptcDataSets::envelope));
ASSERT_EQ("FileFormat", IptcDataSets::dataSetName(IptcDataSets::FileFormat, IptcDataSets::envelope)); ASSERT_EQ("FileFormat", IptcDataSets::dataSetName(IptcDataSets::FileFormat, IptcDataSets::envelope));
@ -21,17 +21,17 @@ TEST(IptcDataSets, dataSetName_returnsValidNamesWhenRequestingNumbersAvailableIn
ASSERT_EQ("EnvelopeNumber", IptcDataSets::dataSetName(IptcDataSets::EnvelopeNumber, IptcDataSets::envelope)); ASSERT_EQ("EnvelopeNumber", IptcDataSets::dataSetName(IptcDataSets::EnvelopeNumber, IptcDataSets::envelope));
} }
TEST(IptcDataSets, dataSetName_returnsValidNamesWhenRequestingNumbersAvailableInApplicationRecord) { TEST(IptcDataSets, dataSetNameReturnsValidNamesWhenRequestingNumbersAvailableInApplicationRecord) {
ASSERT_EQ("ObjectType", IptcDataSets::dataSetName(IptcDataSets::ObjectType, IptcDataSets::application2)); ASSERT_EQ("ObjectType", IptcDataSets::dataSetName(IptcDataSets::ObjectType, IptcDataSets::application2));
ASSERT_EQ("ObjectAttribute", IptcDataSets::dataSetName(IptcDataSets::ObjectAttribute, IptcDataSets::application2)); ASSERT_EQ("ObjectAttribute", IptcDataSets::dataSetName(IptcDataSets::ObjectAttribute, IptcDataSets::application2));
} }
TEST(IptcDataSets, dataSetName_returnsWrongNamesWhenRequestingNumbersNotAvailableInEnvelopeRecord) { TEST(IptcDataSets, dataSetNameReturnsWrongNamesWhenRequestingNumbersNotAvailableInEnvelopeRecord) {
ASSERT_EQ("0x0003", IptcDataSets::dataSetName(IptcDataSets::ObjectType, IptcDataSets::envelope)); ASSERT_EQ("0x0003", IptcDataSets::dataSetName(IptcDataSets::ObjectType, IptcDataSets::envelope));
ASSERT_EQ("0x0004", IptcDataSets::dataSetName(IptcDataSets::ObjectAttribute, IptcDataSets::envelope)); ASSERT_EQ("0x0004", IptcDataSets::dataSetName(IptcDataSets::ObjectAttribute, IptcDataSets::envelope));
} }
TEST(IptcDataSets, dataSetTitle_returnsValidTitleWhenRequestingNumbersAvailableInRecord) { TEST(IptcDataSets, dataSetTitleReturnsValidTitleWhenRequestingNumbersAvailableInRecord) {
ASSERT_STREQ("Model Version", IptcDataSets::dataSetTitle(IptcDataSets::ModelVersion, IptcDataSets::envelope)); ASSERT_STREQ("Model Version", IptcDataSets::dataSetTitle(IptcDataSets::ModelVersion, IptcDataSets::envelope));
ASSERT_STREQ("Destination", IptcDataSets::dataSetTitle(IptcDataSets::Destination, IptcDataSets::envelope)); ASSERT_STREQ("Destination", IptcDataSets::dataSetTitle(IptcDataSets::Destination, IptcDataSets::envelope));
ASSERT_STREQ("File Format", IptcDataSets::dataSetTitle(IptcDataSets::FileFormat, IptcDataSets::envelope)); ASSERT_STREQ("File Format", IptcDataSets::dataSetTitle(IptcDataSets::FileFormat, IptcDataSets::envelope));
@ -41,7 +41,7 @@ TEST(IptcDataSets, dataSetTitle_returnsValidTitleWhenRequestingNumbersAvailableI
IptcDataSets::dataSetTitle(IptcDataSets::ObjectAttribute, IptcDataSets::application2)); IptcDataSets::dataSetTitle(IptcDataSets::ObjectAttribute, IptcDataSets::application2));
} }
TEST(IptcDataSets, dataSetTitle_returnsUnknownStringWhenRequestingNumbersNotAvailableInEnvelopeRecord) { TEST(IptcDataSets, dataSetTitleReturnsUnknownStringWhenRequestingNumbersNotAvailableInEnvelopeRecord) {
ASSERT_STREQ("Unknown dataset", IptcDataSets::dataSetTitle(IptcDataSets::ObjectType, IptcDataSets::envelope)); ASSERT_STREQ("Unknown dataset", IptcDataSets::dataSetTitle(IptcDataSets::ObjectType, IptcDataSets::envelope));
ASSERT_STREQ("Unknown dataset", IptcDataSets::dataSetTitle(IptcDataSets::ObjectAttribute, IptcDataSets::envelope)); ASSERT_STREQ("Unknown dataset", IptcDataSets::dataSetTitle(IptcDataSets::ObjectAttribute, IptcDataSets::envelope));
} }
@ -56,14 +56,14 @@ TEST(IptcDataSets, dataSetTitle_returnsUnknownStringWhenRequestingNumbersNotAvai
// ASSERT_STREQ("Unknown dataset", IptcDataSets::dataSetTitle(IptcDataSets::FileFormat, IptcDataSets::application2)); // ASSERT_STREQ("Unknown dataset", IptcDataSets::dataSetTitle(IptcDataSets::FileFormat, IptcDataSets::application2));
//} //}
TEST(IptcDataSets, dataSetTitle_returnsUnknownStringWhenRequestingNumbersNotAvailableInApplicationRecord) { TEST(IptcDataSets, dataSetTitleReturnsUnknownStringWhenRequestingNumbersNotAvailableInApplicationRecord) {
ASSERT_STREQ("Unknown dataset", IptcDataSets::dataSetTitle(1, IptcDataSets::envelope)); ASSERT_STREQ("Unknown dataset", IptcDataSets::dataSetTitle(1, IptcDataSets::envelope));
ASSERT_STREQ("Unknown dataset", IptcDataSets::dataSetTitle(2, IptcDataSets::envelope)); ASSERT_STREQ("Unknown dataset", IptcDataSets::dataSetTitle(2, IptcDataSets::envelope));
} }
// ---------------------- // ----------------------
TEST(IptcDataSets, dataSetDescription_returnsValidDescriptionWhenRequestingNumbersAvailableInRecord) { TEST(IptcDataSets, dataSetDescriptionReturnsValidDescriptionWhenRequestingNumbersAvailableInRecord) {
ASSERT_THAT(IptcDataSets::dataSetDesc(IptcDataSets::ModelVersion, IptcDataSets::envelope), ASSERT_THAT(IptcDataSets::dataSetDesc(IptcDataSets::ModelVersion, IptcDataSets::envelope),
StartsWith("A binary number identifying the version of the Information Interchange Model")); StartsWith("A binary number identifying the version of the Information Interchange Model"));
ASSERT_THAT(IptcDataSets::dataSetDesc(IptcDataSets::FileFormat, IptcDataSets::envelope), ASSERT_THAT(IptcDataSets::dataSetDesc(IptcDataSets::FileFormat, IptcDataSets::envelope),
@ -75,7 +75,7 @@ TEST(IptcDataSets, dataSetDescription_returnsValidDescriptionWhenRequestingNumbe
StartsWith("The Object Type is used to distinguish between different types of objects within the IIM")); StartsWith("The Object Type is used to distinguish between different types of objects within the IIM"));
} }
TEST(IptcDataSets, dataSetDescription_returnsUnknownStringWhenRequestingNumbersNotAvailableInRecord) { TEST(IptcDataSets, dataSetDescriptionReturnsUnknownStringWhenRequestingNumbersNotAvailableInRecord) {
ASSERT_STREQ("Unknown dataset", IptcDataSets::dataSetDesc(1, IptcDataSets::envelope)); ASSERT_STREQ("Unknown dataset", IptcDataSets::dataSetDesc(1, IptcDataSets::envelope));
ASSERT_STREQ("Unknown dataset", IptcDataSets::dataSetDesc(2, IptcDataSets::envelope)); ASSERT_STREQ("Unknown dataset", IptcDataSets::dataSetDesc(2, IptcDataSets::envelope));
@ -85,14 +85,14 @@ TEST(IptcDataSets, dataSetDescription_returnsUnknownStringWhenRequestingNumbersN
// ---------------------- // ----------------------
TEST(IptcDataSets, dataSetPsName_returnsValidPsNameWhenRequestingNumbersAvailableInRecord) { TEST(IptcDataSets, dataSetPsNameReturnsValidPsNameWhenRequestingNumbersAvailableInRecord) {
ASSERT_STREQ("", IptcDataSets::dataSetPsName(IptcDataSets::FileFormat, IptcDataSets::envelope)); ASSERT_STREQ("", IptcDataSets::dataSetPsName(IptcDataSets::FileFormat, IptcDataSets::envelope));
ASSERT_STREQ("Document Title", IptcDataSets::dataSetPsName(IptcDataSets::ObjectName, IptcDataSets::application2)); ASSERT_STREQ("Document Title", IptcDataSets::dataSetPsName(IptcDataSets::ObjectName, IptcDataSets::application2));
ASSERT_STREQ("Urgency", IptcDataSets::dataSetPsName(IptcDataSets::Urgency, IptcDataSets::application2)); ASSERT_STREQ("Urgency", IptcDataSets::dataSetPsName(IptcDataSets::Urgency, IptcDataSets::application2));
} }
TEST(IptcDataSets, dataSetPsName_returnsUnknownStringWhenRequestingNumbersNotAvailableInRecord) { TEST(IptcDataSets, dataSetPsNameReturnsUnknownStringWhenRequestingNumbersNotAvailableInRecord) {
ASSERT_STREQ("Unknown dataset", IptcDataSets::dataSetPsName(1, IptcDataSets::envelope)); ASSERT_STREQ("Unknown dataset", IptcDataSets::dataSetPsName(1, IptcDataSets::envelope));
ASSERT_STREQ("Unknown dataset", IptcDataSets::dataSetPsName(2, IptcDataSets::envelope)); ASSERT_STREQ("Unknown dataset", IptcDataSets::dataSetPsName(2, IptcDataSets::envelope));
@ -102,7 +102,7 @@ TEST(IptcDataSets, dataSetPsName_returnsUnknownStringWhenRequestingNumbersNotAva
// ---------------------- // ----------------------
TEST(IptcDataSets, dataSetRepeatable_returnsExpectedValueNameWhenRequestingNumbersAvailableInRecord) { TEST(IptcDataSets, dataSetRepeatableReturnsExpectedValueNameWhenRequestingNumbersAvailableInRecord) {
ASSERT_TRUE(IptcDataSets::dataSetRepeatable(IptcDataSets::Destination, IptcDataSets::envelope)); ASSERT_TRUE(IptcDataSets::dataSetRepeatable(IptcDataSets::Destination, IptcDataSets::envelope));
ASSERT_FALSE(IptcDataSets::dataSetRepeatable(IptcDataSets::FileFormat, IptcDataSets::envelope)); ASSERT_FALSE(IptcDataSets::dataSetRepeatable(IptcDataSets::FileFormat, IptcDataSets::envelope));
@ -111,7 +111,7 @@ TEST(IptcDataSets, dataSetRepeatable_returnsExpectedValueNameWhenRequestingNumbe
} }
/// \todo check if we want to return true in this case or throw an exception ... /// \todo check if we want to return true in this case or throw an exception ...
TEST(IptcDataSets, dataSetRepeatable_returnsTrueWhenRequestingNumbersNotAvailableInRecord) { TEST(IptcDataSets, dataSetRepeatableReturnsTrueWhenRequestingNumbersNotAvailableInRecord) {
ASSERT_TRUE(IptcDataSets::dataSetRepeatable(1, IptcDataSets::envelope)); ASSERT_TRUE(IptcDataSets::dataSetRepeatable(1, IptcDataSets::envelope));
ASSERT_TRUE(IptcDataSets::dataSetRepeatable(2, IptcDataSets::envelope)); ASSERT_TRUE(IptcDataSets::dataSetRepeatable(2, IptcDataSets::envelope));
@ -121,7 +121,7 @@ TEST(IptcDataSets, dataSetRepeatable_returnsTrueWhenRequestingNumbersNotAvailabl
// ---------------------- // ----------------------
TEST(IptcDataSets, dataSet_returnsExpectedValueWhenRequestingValidDatasetName) { TEST(IptcDataSets, dataSetReturnsExpectedValueWhenRequestingValidDatasetName) {
ASSERT_EQ(IptcDataSets::ModelVersion, IptcDataSets::dataSet("ModelVersion", IptcDataSets::envelope)); ASSERT_EQ(IptcDataSets::ModelVersion, IptcDataSets::dataSet("ModelVersion", IptcDataSets::envelope));
ASSERT_EQ(IptcDataSets::FileFormat, IptcDataSets::dataSet("FileFormat", IptcDataSets::envelope)); ASSERT_EQ(IptcDataSets::FileFormat, IptcDataSets::dataSet("FileFormat", IptcDataSets::envelope));
@ -129,7 +129,7 @@ TEST(IptcDataSets, dataSet_returnsExpectedValueWhenRequestingValidDatasetName) {
ASSERT_EQ(IptcDataSets::FixtureId, IptcDataSets::dataSet("FixtureId", IptcDataSets::application2)); ASSERT_EQ(IptcDataSets::FixtureId, IptcDataSets::dataSet("FixtureId", IptcDataSets::application2));
} }
TEST(IptcDataSets, dataSet_throwWithNonExistingDatasetName) { TEST(IptcDataSets, dataSetThrowWithNonExistingDatasetName) {
try { try {
IptcDataSets::dataSet("NonExistingName", IptcDataSets::envelope); IptcDataSets::dataSet("NonExistingName", IptcDataSets::envelope);
FAIL(); FAIL();
@ -140,7 +140,7 @@ TEST(IptcDataSets, dataSet_throwWithNonExistingDatasetName) {
} }
/// \todo Weird error reporting here. It should indicate that the record specified does not exist /// \todo Weird error reporting here. It should indicate that the record specified does not exist
TEST(IptcDataSets, dataSet_throwWithNonExistingRecordId) { TEST(IptcDataSets, dataSetThrowWithNonExistingRecordId) {
try { try {
IptcDataSets::dataSet("ModelVersion", 5); IptcDataSets::dataSet("ModelVersion", 5);
FAIL(); FAIL();
@ -152,7 +152,7 @@ TEST(IptcDataSets, dataSet_throwWithNonExistingRecordId) {
// ---------------------- // ----------------------
TEST(IptcDataSets, dataSetType_returnsExpectedTypeWhenRequestingValidDataset) { TEST(IptcDataSets, dataSetTypeReturnsExpectedTypeWhenRequestingValidDataset) {
ASSERT_EQ(unsignedShort, IptcDataSets::dataSetType(IptcDataSets::ModelVersion, IptcDataSets::envelope)); ASSERT_EQ(unsignedShort, IptcDataSets::dataSetType(IptcDataSets::ModelVersion, IptcDataSets::envelope));
ASSERT_EQ(Exiv2::string, IptcDataSets::dataSetType(IptcDataSets::Destination, IptcDataSets::envelope)); ASSERT_EQ(Exiv2::string, IptcDataSets::dataSetType(IptcDataSets::Destination, IptcDataSets::envelope));
@ -161,49 +161,49 @@ TEST(IptcDataSets, dataSetType_returnsExpectedTypeWhenRequestingValidDataset) {
} }
/// \todo probably better to throw exception here? /// \todo probably better to throw exception here?
TEST(IptcDataSets, dataSetType_returnsStringTypeWhenRecordIdDoesNotExist) { TEST(IptcDataSets, dataSetTypeReturnsStringTypeWhenRecordIdDoesNotExist) {
ASSERT_EQ(Exiv2::string, IptcDataSets::dataSetType(1, 5)); ASSERT_EQ(Exiv2::string, IptcDataSets::dataSetType(1, 5));
} }
// ---------------------- // ----------------------
TEST(IptcDataSets, recordName_returnsExpectedNameWhenRequestingValidRecordId) { TEST(IptcDataSets, recordNameReturnsExpectedNameWhenRequestingValidRecordId) {
ASSERT_EQ("Envelope", IptcDataSets::recordName(IptcDataSets::envelope)); ASSERT_EQ("Envelope", IptcDataSets::recordName(IptcDataSets::envelope));
ASSERT_EQ("Application2", IptcDataSets::recordName(IptcDataSets::application2)); ASSERT_EQ("Application2", IptcDataSets::recordName(IptcDataSets::application2));
} }
TEST(IptcDataSets, recordName_returnsHexStringWhenRecordIdDoesNotExist) { TEST(IptcDataSets, recordNameReturnsHexStringWhenRecordIdDoesNotExist) {
ASSERT_EQ("0x0000", IptcDataSets::recordName(0)); ASSERT_EQ("0x0000", IptcDataSets::recordName(0));
ASSERT_EQ("0x0003", IptcDataSets::recordName(3)); ASSERT_EQ("0x0003", IptcDataSets::recordName(3));
} }
// ---------------------- // ----------------------
TEST(IptcDataSets, recordDesc_returnsExpectedDescriptionWhenRequestingValidRecordId) { TEST(IptcDataSets, recordDescReturnsExpectedDescriptionWhenRequestingValidRecordId) {
ASSERT_STREQ("IIM envelope record", IptcDataSets::recordDesc(IptcDataSets::envelope)); ASSERT_STREQ("IIM envelope record", IptcDataSets::recordDesc(IptcDataSets::envelope));
ASSERT_STREQ("IIM application record 2", IptcDataSets::recordDesc(IptcDataSets::application2)); ASSERT_STREQ("IIM application record 2", IptcDataSets::recordDesc(IptcDataSets::application2));
} }
TEST(IptcDataSets, recordDesc_) { TEST(IptcDataSets, recordDesc) {
ASSERT_STREQ("Unknown dataset", IptcDataSets::recordDesc(0)); ASSERT_STREQ("Unknown dataset", IptcDataSets::recordDesc(0));
ASSERT_STREQ("Unknown dataset", IptcDataSets::recordDesc(3)); ASSERT_STREQ("Unknown dataset", IptcDataSets::recordDesc(3));
} }
// ---------------------- // ----------------------
TEST(IptcDataSets, recordId_returnsExpectedIdWithValidRecordName) { TEST(IptcDataSets, recordIdReturnsExpectedIdWithValidRecordName) {
ASSERT_EQ(IptcDataSets::envelope, IptcDataSets::recordId("Envelope")); ASSERT_EQ(IptcDataSets::envelope, IptcDataSets::recordId("Envelope"));
ASSERT_EQ(IptcDataSets::application2, IptcDataSets::recordId("Application2")); ASSERT_EQ(IptcDataSets::application2, IptcDataSets::recordId("Application2"));
} }
TEST(IptcDataSets, recordId_throwsExceptionWithInvalidRecordName) { TEST(IptcDataSets, recordIdThrowsExceptionWithInvalidRecordName) {
ASSERT_THROW(IptcDataSets::recordId("NonExistingName"), Exiv2::Error); ASSERT_THROW(IptcDataSets::recordId("NonExistingName"), Exiv2::Error);
ASSERT_THROW(IptcDataSets::recordId(""), Exiv2::Error); ASSERT_THROW(IptcDataSets::recordId(""), Exiv2::Error);
} }
// ---------------------- // ----------------------
TEST(IptcDataSets, dataSetLists_printDatasetsIntoOstream) { TEST(IptcDataSets, dataSetListsPrintDatasetsIntoOstream) {
std::ostringstream stream; std::ostringstream stream;
ASSERT_NO_THROW(IptcDataSets::dataSetList(stream)); ASSERT_NO_THROW(IptcDataSets::dataSetList(stream));
ASSERT_FALSE(stream.str().empty()); ASSERT_FALSE(stream.str().empty());

@ -3,7 +3,7 @@
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include "helper_functions.hpp" #include "helper_functions.hpp"
TEST(string_from_unterminated, terminatedArray) { TEST(stringFromUnterminated, terminatedArray) {
const char data[5] = {'a', 'b', 'c', 0, 'd'}; const char data[5] = {'a', 'b', 'c', 0, 'd'};
const std::string res = string_from_unterminated(data, 5); const std::string res = string_from_unterminated(data, 5);
@ -11,7 +11,7 @@ TEST(string_from_unterminated, terminatedArray) {
ASSERT_STREQ(res.c_str(), "abc"); ASSERT_STREQ(res.c_str(), "abc");
} }
TEST(string_from_unterminated, unterminatedArray) { TEST(stringFromUnterminated, unterminatedArray) {
const char data[4] = {'a', 'b', 'c', 'd'}; const char data[4] = {'a', 'b', 'c', 'd'};
const std::string res = string_from_unterminated(data, 4); const std::string res = string_from_unterminated(data, 4);

@ -24,18 +24,18 @@ void setValidValues(std::vector<std::uint8_t>& boxData) {
} }
} // namespace } // namespace
TEST(Jp2_FileTypeBox, isNotValidWithoutProperValuesSet) { TEST(Jp2FileTypeBox, isNotValidWithoutProperValuesSet) {
const std::vector<std::uint8_t> boxData(12); const std::vector<std::uint8_t> boxData(12);
ASSERT_FALSE(isValidBoxFileType(boxData)); ASSERT_FALSE(isValidBoxFileType(boxData));
} }
TEST(Jp2_FileTypeBox, isValidWithMinimumPossibleSizeAndValidValues) { TEST(Jp2FileTypeBox, isValidWithMinimumPossibleSizeAndValidValues) {
std::vector<std::uint8_t> boxData(12); std::vector<std::uint8_t> boxData(12);
setValidValues(boxData); setValidValues(boxData);
ASSERT_TRUE(isValidBoxFileType(boxData)); ASSERT_TRUE(isValidBoxFileType(boxData));
} }
TEST(Jp2_FileTypeBox, isNotValidWithMinimumPossibleSizeButInvalidBrand) { TEST(Jp2FileTypeBox, isNotValidWithMinimumPossibleSizeButInvalidBrand) {
std::vector<std::uint8_t> boxData(12); std::vector<std::uint8_t> boxData(12);
setValidValues(boxData); setValidValues(boxData);
boxData[2] = '3'; // Change byte in the brand field boxData[2] = '3'; // Change byte in the brand field
@ -43,7 +43,7 @@ TEST(Jp2_FileTypeBox, isNotValidWithMinimumPossibleSizeButInvalidBrand) {
ASSERT_FALSE(isValidBoxFileType(boxData)); ASSERT_FALSE(isValidBoxFileType(boxData));
} }
TEST(Jp2_FileTypeBox, isNotValidWithMinimumPossibleSizeButInvalidCL1) { TEST(Jp2FileTypeBox, isNotValidWithMinimumPossibleSizeButInvalidCL1) {
std::vector<std::uint8_t> boxData(12); std::vector<std::uint8_t> boxData(12);
setValidValues(boxData); setValidValues(boxData);
boxData[10] = '3'; // Change byte in the CL1 boxData[10] = '3'; // Change byte in the CL1
@ -53,17 +53,17 @@ TEST(Jp2_FileTypeBox, isNotValidWithMinimumPossibleSizeButInvalidCL1) {
// ---------------------------------------------------------- // ----------------------------------------------------------
TEST(Jp2_FileTypeBox, withInvalidBoxDataSizeIsInvalid) { TEST(Jp2FileTypeBox, withInvalidBoxDataSizeIsInvalid) {
std::vector<std::uint8_t> boxData(13); // 12 + 1 (the extra byte causes problems) std::vector<std::uint8_t> boxData(13); // 12 + 1 (the extra byte causes problems)
ASSERT_FALSE(isValidBoxFileType(boxData)); ASSERT_FALSE(isValidBoxFileType(boxData));
} }
TEST(Jp2_FileTypeBox, withSmallBoxDataSizeIsInvalid) { TEST(Jp2FileTypeBox, withSmallBoxDataSizeIsInvalid) {
std::vector<std::uint8_t> boxData(7); // Minimum size is 8 std::vector<std::uint8_t> boxData(7); // Minimum size is 8
ASSERT_FALSE(isValidBoxFileType(boxData)); ASSERT_FALSE(isValidBoxFileType(boxData));
} }
TEST(Jp2_FileTypeBox, with2CLs_lastOneWithBrandValue_isValid) { TEST(Jp2FileTypeBox, with2CLsLastOneWithBrandValueIsValid) {
std::vector<std::uint8_t> boxData(16); std::vector<std::uint8_t> boxData(16);
// The first 4 bytes correspond to the BR (Brand). It must have the value 'jp2\040' // The first 4 bytes correspond to the BR (Brand). It must have the value 'jp2\040'
boxData[0] = 'j'; boxData[0] = 'j';

@ -53,7 +53,7 @@ TEST(DataBuf, tryingToAccessTooFarElementThrows) {
ASSERT_THROW([[maybe_unused]] auto d = instance.c_data(4), std::out_of_range); ASSERT_THROW([[maybe_unused]] auto d = instance.c_data(4), std::out_of_range);
} }
TEST(DataBuf, read_uintFunctionsWorksOnExistingData) { TEST(DataBuf, readUintFunctionsWorksOnExistingData) {
const std::array<byte, 8> data{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07}; const std::array<byte, 8> data{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07};
DataBuf instance(data.data(), data.size()); DataBuf instance(data.data(), data.size());
ASSERT_EQ(data[0], instance.read_uint8(0)); ASSERT_EQ(data[0], instance.read_uint8(0));
@ -62,7 +62,7 @@ TEST(DataBuf, read_uintFunctionsWorksOnExistingData) {
ASSERT_EQ(0x0001020304050607, instance.read_uint64(0, bigEndian)); ASSERT_EQ(0x0001020304050607, instance.read_uint64(0, bigEndian));
} }
TEST(DataBuf, read_uintFunctionsThrowsOnTooFarElements) { TEST(DataBuf, readUintFunctionsThrowsOnTooFarElements) {
const std::array<byte, 8> data{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07}; const std::array<byte, 8> data{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07};
DataBuf instance(data.data(), data.size()); DataBuf instance(data.data(), data.size());
ASSERT_THROW([[maybe_unused]] auto d = instance.read_uint8(data.size()), std::out_of_range); ASSERT_THROW([[maybe_unused]] auto d = instance.read_uint8(data.size()), std::out_of_range);
@ -71,7 +71,7 @@ TEST(DataBuf, read_uintFunctionsThrowsOnTooFarElements) {
ASSERT_THROW([[maybe_unused]] auto d = instance.read_uint64(data.size(), bigEndian), std::out_of_range); ASSERT_THROW([[maybe_unused]] auto d = instance.read_uint64(data.size(), bigEndian), std::out_of_range);
} }
TEST(DataBuf, write_uintFunctionsWorksWhenThereIsEnoughData) { TEST(DataBuf, writeUintFunctionsWorksWhenThereIsEnoughData) {
DataBuf instance(8); DataBuf instance(8);
std::uint64_t val{0x0102030405060708}; std::uint64_t val{0x0102030405060708};
ASSERT_NO_THROW(instance.write_uint8(0, (val >> 56))); ASSERT_NO_THROW(instance.write_uint8(0, (val >> 56)));
@ -87,7 +87,7 @@ TEST(DataBuf, write_uintFunctionsWorksWhenThereIsEnoughData) {
ASSERT_EQ(val, instance.read_uint64(0, bigEndian)); ASSERT_EQ(val, instance.read_uint64(0, bigEndian));
} }
TEST(DataBuf, write_uintFunctionsThrowsIfTryingToWriteOutOfBounds) { TEST(DataBuf, writeUintFunctionsThrowsIfTryingToWriteOutOfBounds) {
DataBuf instance(8); DataBuf instance(8);
std::uint64_t val{0x0102030405060708}; std::uint64_t val{0x0102030405060708};
ASSERT_THROW(instance.write_uint8(8, (val >> 56)), std::out_of_range); ASSERT_THROW(instance.write_uint8(8, (val >> 56)), std::out_of_range);
@ -97,7 +97,7 @@ TEST(DataBuf, write_uintFunctionsThrowsIfTryingToWriteOutOfBounds) {
} }
// Test methods like DataBuf::read_uint32 and DataBuf::write_uint32. // Test methods like DataBuf::read_uint32 and DataBuf::write_uint32.
TEST(DataBuf, read_write_endianess) { TEST(DataBuf, readWriteEndianess) {
DataBuf buf(4 + 1 + 2 + 4 + 8); DataBuf buf(4 + 1 + 2 + 4 + 8);
// Big endian. // Big endian.

Loading…
Cancel
Save