Skip to content

Commit

Permalink
unitTests: fix sign comparison warnings
Browse files Browse the repository at this point in the history
Signed-off-by: Rosen Penev <rosenp@gmail.com>
  • Loading branch information
neheb committed Feb 17, 2024
1 parent 84ce408 commit 2c1eb87
Show file tree
Hide file tree
Showing 12 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion unitTests/test_DateValue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ TEST(ADateValue, copiesToByteBufferWithBasicFormat) {
std::array<byte, 8> buf = {};

const byte expectedDate[10] = {'2', '0', '2', '1', '1', '2', '0', '1'};
ASSERT_EQ(8, dateValue.copy(buf.data()));
ASSERT_EQ(8u, dateValue.copy(buf.data()));
ASSERT_TRUE(std::equal(buf.begin(), buf.end(), expectedDate));
}

Expand Down
2 changes: 1 addition & 1 deletion unitTests/test_FileIo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ TEST(AFileIO, returnsFileSizeEvenWhenFileItIsNotOpened) {
TEST(AFileIO, isOpenedAtPosition0) {
FileIo file(imagePath);
file.open();
ASSERT_EQ(0, file.tell());
ASSERT_EQ(0u, file.tell());
}

TEST(AFileIO, canSeekToExistingPositions) {
Expand Down
8 changes: 4 additions & 4 deletions unitTests/test_Photoshop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ TEST(PhotoshopLocateIrb, returns0withGoodIptcIrb) {
uint32_t sizeData = 0;

ASSERT_EQ(0, Photoshop::locateIrb(data.data(), data.size(), Photoshop::iptc_, &record, sizeHdr, sizeData));
ASSERT_EQ(12, sizeHdr);
ASSERT_EQ(27, sizeData);
ASSERT_EQ(12u, sizeHdr);
ASSERT_EQ(27u, sizeData);
}

TEST(PhotoshopLocateIptcIrb, returns0withGoodIptcIrb) {
Expand All @@ -94,8 +94,8 @@ TEST(PhotoshopLocateIptcIrb, returns0withGoodIptcIrb) {
uint32_t sizeData = 0;

ASSERT_EQ(0, Photoshop::locateIptcIrb(data.data(), data.size(), &record, sizeHdr, sizeData));
ASSERT_EQ(12, sizeHdr);
ASSERT_EQ(27, sizeData);
ASSERT_EQ(12u, sizeHdr);
ASSERT_EQ(27u, sizeData);
}

TEST(PhotoshopLocateIptcIrb, returns3withoutIptcMarker) {
Expand Down
2 changes: 1 addition & 1 deletion unitTests/test_TimeValue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ TEST(ATimeValue, cannotReadFromStringWithBadFormat) {
TEST(ATimeValue, isCopiedToBuffer) {
const TimeValue value(23, 55, 2);
byte buffer[11];
ASSERT_EQ(11, value.copy(buffer));
ASSERT_EQ(11u, value.copy(buffer));

const byte expectedDate[11] = {'2', '3', '5', '5', '0', '2', '+', '0', '0', '0', '0'};
for (int i = 0; i < 11; ++i) {
Expand Down
2 changes: 1 addition & 1 deletion unitTests/test_asfvideo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,5 @@ TEST(AsfVideo, readMetadata) {
ASSERT_NO_THROW(asf.setXmpData(xmpData));
auto data = asf.xmpData();
ASSERT_FALSE(data.empty());
ASSERT_EQ(xmpData["Xmp.video.TotalStream"].count(), 4);
ASSERT_EQ(xmpData["Xmp.video.TotalStream"].count(), 4u);
}
8 changes: 4 additions & 4 deletions unitTests/test_basicio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ using namespace Exiv2;
TEST(MemIoDefault, readEReturns0) {
std::array<byte, 10> buf;
MemIo io;
ASSERT_EQ(0, io.read(buf.data(), buf.size()));
ASSERT_EQ(0u, io.read(buf.data(), buf.size()));
}

TEST(MemIoDefault, isNotAtEof) {
Expand All @@ -32,9 +32,9 @@ TEST(MemIoDefault, seekBefore0Returns1ButItDoesNotSetEofToTrue) {

TEST(MemIoDefault, seekToEndPositionDoesNotTriggerEof) {
MemIo io;
ASSERT_EQ(0, io.tell());
ASSERT_EQ(0u, io.tell());
ASSERT_EQ(0, io.seek(0, BasicIo::end));
ASSERT_EQ(0, io.tell());
ASSERT_EQ(0u, io.tell());
ASSERT_FALSE(io.eof());
}

Expand All @@ -44,7 +44,7 @@ TEST(MemIoDefault, seekToEndPositionAndReadTriggersEof) {
ASSERT_EQ(0, io.tell());

std::array<byte, 64> buf2 = {};
ASSERT_EQ(0, io.read(buf2.data(), 1)); // Note that we cannot even read 1 byte being at the end
ASSERT_EQ(0u, io.read(buf2.data(), 1)); // Note that we cannot even read 1 byte being at the end
ASSERT_TRUE(io.eof());
}

Expand Down
4 changes: 2 additions & 2 deletions unitTests/test_bmpimage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ TEST(BmpImage, readMetadataReadsImageDimensionsWhenDataIsAvailable) {
auto memIo = std::make_unique<MemIo>(header.data(), header.size());
BmpImage bmp(std::move(memIo));
ASSERT_NO_THROW(bmp.readMetadata());
ASSERT_EQ(1280, bmp.pixelWidth());
ASSERT_EQ(800, bmp.pixelHeight());
ASSERT_EQ(1280u, bmp.pixelWidth());
ASSERT_EQ(800u, bmp.pixelHeight());
}

TEST(BmpImage, readMetadataThrowsWhenImageIsNotBMP) {
Expand Down
2 changes: 1 addition & 1 deletion unitTests/test_futils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ TEST(base64decode, decodesValidString) {
const std::string original("VGhpcyBpcyBhIHVuaXQgdGVzdA==");
const std::string expected("This is a unit test");
std::vector<char> result(original.size());
ASSERT_EQ(static_cast<long>(expected.size()), base64decode(original.c_str(), result.data(), original.size()));
ASSERT_EQ(expected.size(), base64decode(original.c_str(), result.data(), original.size()));
ASSERT_STREQ(expected.c_str(), result.data());
}

Expand Down
2 changes: 1 addition & 1 deletion unitTests/test_matroskavideo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,5 @@ TEST(MatroskaVideo, readMetadata) {
ASSERT_NO_THROW(mkv.setXmpData(xmpData));
auto data = mkv.xmpData();
ASSERT_FALSE(data.empty());
ASSERT_EQ(xmpData["Xmp.video.TotalStream"].count(), 4);
ASSERT_EQ(xmpData["Xmp.video.TotalStream"].count(), 4u);
}
2 changes: 1 addition & 1 deletion unitTests/test_pngimage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ TEST(PngChunk, keyTxtChunkExtractsKeywordCorrectlyInPresenceOfNullChar) {

DataBuf chunkBuf(data.data(), data.size());
DataBuf key = Internal::PngChunk::keyTXTChunk(chunkBuf, true);
ASSERT_EQ(21, key.size());
ASSERT_EQ(21u, key.size());

ASSERT_TRUE(std::equal(key.data(), key.data() + key.size(), data.data() + 8));
}
Expand Down
2 changes: 1 addition & 1 deletion unitTests/test_riffVideo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,5 @@ TEST(RiffVideo, readMetadata) {
ASSERT_NO_THROW(riff.setXmpData(xmpData));
auto data = riff.xmpData();
ASSERT_FALSE(data.empty());
ASSERT_EQ(xmpData["Xmp.video.TotalStream"].count(), 4);
ASSERT_EQ(xmpData["Xmp.video.TotalStream"].count(), 4u);
}
6 changes: 3 additions & 3 deletions unitTests/test_types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ TEST(DataBuf, defaultInstanceIsEmpty) {
TEST(DataBuf, allocatesDataWithNonEmptyConstructor) {
DataBuf instance(5);
ASSERT_NE(nullptr, instance.c_data());
ASSERT_EQ(5, instance.size());
ASSERT_EQ(5u, instance.size());
}

TEST(DataBuf, canBeConstructedFromExistingData) {
Expand All @@ -58,8 +58,8 @@ TEST(DataBuf, readUintFunctionsWorksOnExistingData) {
DataBuf instance(data.data(), data.size());
ASSERT_EQ(data[0], instance.read_uint8(0));
ASSERT_EQ(data[1], instance.read_uint16(0, bigEndian));
ASSERT_EQ(0x00010203, instance.read_uint32(0, bigEndian));
ASSERT_EQ(0x0001020304050607, instance.read_uint64(0, bigEndian));
ASSERT_EQ(0x00010203u, instance.read_uint32(0, bigEndian));
ASSERT_EQ(0x0001020304050607u, instance.read_uint64(0, bigEndian));
}

TEST(DataBuf, readUintFunctionsThrowsOnTooFarElements) {
Expand Down

0 comments on commit 2c1eb87

Please sign in to comment.