Add new BMP tests

main
Luis Diaz 3 years ago committed by Luis Díaz Más
parent 8505f4d935
commit edf39e00dd

@ -84,20 +84,11 @@ namespace Exiv2 {
yet(?) implemented. Calling it will throw an Error(kerWritingImageFormatUnsupported).
*/
void writeMetadata() override;
/*!
@brief Todo: Not supported yet(?). Calling this function will throw
an instance of Error(kerInvalidSettingForImage).
*/
void setExifData(const ExifData& exifData) override;
/*!
@brief Todo: Not supported yet(?). Calling this function will throw
an instance of Error(kerInvalidSettingForImage).
*/
void setIptcData(const IptcData& iptcData) override;
/*!
@brief Not supported. Calling this function will throw an instance
of Error(kerInvalidSettingForImage).
*/
void setComment(const std::string& comment) override;
//@}

@ -47,24 +47,22 @@ namespace Exiv2
std::string BmpImage::mimeType() const
{
return "image/x-ms-bmp";
// "image/bmp" is a Generic Bitmap
return "image/x-ms-bmp"; // Microsoft Bitmap
}
void BmpImage::setExifData(const ExifData& /*exifData*/)
{
// Todo: implement me!
throw(Error(kerInvalidSettingForImage, "Exif metadata", "BMP"));
}
void BmpImage::setIptcData(const IptcData& /*iptcData*/)
{
// Todo: implement me!
throw(Error(kerInvalidSettingForImage, "IPTC metadata", "BMP"));
}
void BmpImage::setComment(const std::string& /*comment*/)
{
// not supported
throw(Error(kerInvalidSettingForImage, "Image comment", "BMP"));
}
@ -77,9 +75,11 @@ namespace Exiv2
throw Error(kerDataSourceOpenFailed, io_->path(), strError());
}
IoCloser closer(*io_);
// Ensure that this is the correct image type
if (!isBmpType(*io_, false)) {
if (io_->error() || io_->eof()) throw Error(kerFailedToReadImageData);
if (io_->error() || io_->eof())
throw Error(kerFailedToReadImageData);
throw Error(kerNotAnImage, "BMP");
}
clearMetadata();

@ -2,6 +2,7 @@ find_package(GTest REQUIRED)
add_executable(unit_tests
mainTestRunner.cpp
test_bmpimage.cpp
test_DateValue.cpp
test_TimeValue.cpp
test_XmpKey.cpp

@ -0,0 +1,21 @@
#include <exiv2/bmpimage.hpp>
#include <gtest/gtest.h>
#include <array>
using namespace Exiv2;
TEST(BmpImage, canBeOpenedWithEmptyMemIo)
{
auto memIo = std::make_unique<MemIo>();
ASSERT_NO_THROW(BmpImage bmp(std::move(memIo)));
}
TEST(BmpImage, mimeTypeIsBmp)
{
auto memIo = std::make_unique<MemIo>();
BmpImage bmp(std::move(memIo));
ASSERT_EQ("image/x-ms-bmp", bmp.mimeType());
}

@ -158,6 +158,14 @@ TEST(PngImage, cannotWriteMetadataToEmptyIo)
}
}
TEST(PngImage, canWriteMetadataFromCreatedPngImage)
{
auto memIo = std::make_unique<MemIo>();
const bool create {true};
PngImage png(std::move(memIo), create);
ASSERT_NO_THROW(png.writeMetadata());
}
TEST(PngImage, cannotWriteMetadataToIoWhichCannotBeOpened)
{
auto memIo = std::make_unique<FileIo>("NonExistingPath.png");

Loading…
Cancel
Save