Fix MSVC warnings by casting integer values

main
Luis Diaz 3 years ago committed by Luis Díaz Más
parent 9b40f948eb
commit 9573f1edcc

@ -90,7 +90,7 @@ TEST(BmpImage, readMetadataReadsImageDimensionsWhenDataIsAvailable)
0x20, 0x03, 0x00, 0x00, // The bitmap height in pixels (unsigned 16 bit) off:22, size:4 0x20, 0x03, 0x00, 0x00, // The bitmap height in pixels (unsigned 16 bit) off:22, size:4
}; };
auto memIo = std::make_unique<MemIo>(header.data(), header.size()); auto memIo = std::make_unique<MemIo>(header.data(), static_cast<long>(header.size()));
BmpImage bmp(std::move(memIo)); BmpImage bmp(std::move(memIo));
ASSERT_NO_THROW(bmp.readMetadata()); ASSERT_NO_THROW(bmp.readMetadata());
ASSERT_EQ(1280, bmp.pixelWidth()); ASSERT_EQ(1280, bmp.pixelWidth());
@ -110,7 +110,7 @@ TEST(BmpImage, readMetadataThrowsWhenImageIsNotBMP)
0x20, 0x03, 0x00, 0x00, // The bitmap height in pixels (unsigned 16 bit) off:22, size:4 0x20, 0x03, 0x00, 0x00, // The bitmap height in pixels (unsigned 16 bit) off:22, size:4
}; };
auto memIo = std::make_unique<MemIo>(header.data(), header.size()); auto memIo = std::make_unique<MemIo>(header.data(), static_cast<long>(header.size()));
BmpImage bmp(std::move(memIo)); BmpImage bmp(std::move(memIo));
try { try {
bmp.readMetadata(); bmp.readMetadata();
@ -124,7 +124,7 @@ TEST(BmpImage, readMetadataThrowsWhenImageIsNotBMP)
TEST(BmpImage, readMetadataThrowsWhenThereIsNotEnoughInfoToRead) TEST(BmpImage, readMetadataThrowsWhenThereIsNotEnoughInfoToRead)
{ {
const std::array<unsigned char, 1> header{'B'}; const std::array<unsigned char, 1> header{'B'};
auto memIo = std::make_unique<MemIo>(header.data(), header.size()); auto memIo = std::make_unique<MemIo>(header.data(), static_cast<long>(header.size()));
BmpImage bmp(std::move(memIo)); BmpImage bmp(std::move(memIo));
try { try {
bmp.readMetadata(); bmp.readMetadata();
@ -157,7 +157,7 @@ TEST(newBmpInstance, createsValidInstace)
0x00, 0x00, // Reserved 0x00, 0x00, // Reserved
0x00, 0x00, 0x00, 0x00 // Offset of the byte where the bitmap image data can be found 0x00, 0x00, 0x00, 0x00 // Offset of the byte where the bitmap image data can be found
}; };
auto memIo = std::make_unique<MemIo>(bitmapHeader.data(), bitmapHeader.size()); auto memIo = std::make_unique<MemIo>(bitmapHeader.data(), static_cast<long>(bitmapHeader.size()));
auto img = newBmpInstance(std::move(memIo), false); auto img = newBmpInstance(std::move(memIo), false);
ASSERT_TRUE(img->good()); ASSERT_TRUE(img->good());
} }
@ -178,7 +178,7 @@ TEST(isBmpType, withValidSignatureReturnsTrue)
0x00, 0x00, // Reserved 0x00, 0x00, // Reserved
0x00, 0x00, 0x00, 0x00 // Offset of the byte where the bitmap image data can be found 0x00, 0x00, 0x00, 0x00 // Offset of the byte where the bitmap image data can be found
}; };
MemIo memIo(bitmapHeader.data(), bitmapHeader.size()); MemIo memIo(bitmapHeader.data(), static_cast<long>(bitmapHeader.size()));
ASSERT_TRUE(isBmpType(memIo, false)); ASSERT_TRUE(isBmpType(memIo, false));
} }
@ -191,6 +191,6 @@ TEST(isBmpType, withInvalidSignatureReturnsFalse)
0x00, 0x00, // Reserved 0x00, 0x00, // Reserved
0x00, 0x00, 0x00, 0x00 // Offset of the byte where the bitmap image data can be found 0x00, 0x00, 0x00, 0x00 // Offset of the byte where the bitmap image data can be found
}; };
MemIo memIo(bitmapHeader.data(), bitmapHeader.size()); MemIo memIo(bitmapHeader.data(), static_cast<long>(bitmapHeader.size()));
ASSERT_FALSE(isBmpType(memIo, false)); ASSERT_FALSE(isBmpType(memIo, false));
} }

Loading…
Cancel
Save