Add new tests for Iptc classes
This commit is contained in:
parent
df0b7c450d
commit
d8fcbc4562
@ -55,11 +55,11 @@ namespace {
|
||||
{ Exiv2::kerNotAnImage,
|
||||
N_("This does not look like a %1 image") }, // %1=Image type
|
||||
{ Exiv2::kerInvalidDataset,
|
||||
N_("Invalid dataset name `%1'") }, // %1=dataset name
|
||||
N_("Invalid dataset name '%1'") }, // %1=dataset name
|
||||
{ Exiv2::kerInvalidRecord,
|
||||
N_("Invalid record name `%1'") }, // %1=record name
|
||||
N_("Invalid record name '%1'") }, // %1=record name
|
||||
{ Exiv2::kerInvalidKey,
|
||||
N_("Invalid key `%1'") }, // %1=key
|
||||
N_("Invalid key '%1'") }, // %1=key
|
||||
{ Exiv2::kerInvalidTag,
|
||||
N_("Invalid tag name or ifdId `%1', ifdId %2") }, // %1=tag name, %2=ifdId
|
||||
{ Exiv2::kerValueNotSet,
|
||||
|
||||
@ -14,6 +14,7 @@ add_executable(unit_tests
|
||||
test_futils.cpp
|
||||
test_helper_functions.cpp
|
||||
test_image_int.cpp
|
||||
test_IptcKey.cpp
|
||||
test_pngimage.cpp
|
||||
test_safe_op.cpp
|
||||
test_slice.cpp
|
||||
|
||||
44
unitTests/test_IptcKey.cpp
Normal file
44
unitTests/test_IptcKey.cpp
Normal file
@ -0,0 +1,44 @@
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include <exiv2/datasets.hpp>
|
||||
#include <exiv2/error.hpp>
|
||||
|
||||
using namespace Exiv2;
|
||||
|
||||
TEST(IptcKey, creationWithNonValidStringFormatThrows)
|
||||
{
|
||||
try {
|
||||
IptcKey key("Yeah");
|
||||
FAIL();
|
||||
} catch (const Exiv2::Error& e) {
|
||||
ASSERT_EQ(kerInvalidKey, e.code());
|
||||
ASSERT_STREQ("Invalid key 'Yeah'", e.what());
|
||||
}
|
||||
}
|
||||
|
||||
TEST(IptcKey, creationWithNonValidRecordNameThrows)
|
||||
{
|
||||
try {
|
||||
IptcKey key("Iptc.WrongRecordName.ModelVersion");
|
||||
FAIL();
|
||||
} catch (const Exiv2::Error& e) {
|
||||
ASSERT_EQ(kerInvalidRecord, e.code());
|
||||
ASSERT_STREQ("Invalid record name 'WrongRecordName'", e.what());
|
||||
}
|
||||
}
|
||||
|
||||
TEST(IptcKey, creationWithNonValidDatasetNameThrows)
|
||||
{
|
||||
try {
|
||||
IptcKey key("Iptc.Envelope.WrongDataset");
|
||||
FAIL();
|
||||
} catch (const Exiv2::Error& e) {
|
||||
ASSERT_EQ(kerInvalidDataset, e.code());
|
||||
ASSERT_STREQ("Invalid dataset name 'WrongDataset'", e.what());
|
||||
}
|
||||
}
|
||||
|
||||
TEST(IptcKey, creationWithValidStringDoesNotThrow)
|
||||
{
|
||||
ASSERT_NO_THROW(IptcKey ("Iptc.Envelope.ModelVersion"));
|
||||
}
|
||||
@ -5,6 +5,7 @@
|
||||
#include <exiv2/error.hpp>
|
||||
|
||||
#include <array>
|
||||
#include <sstream>
|
||||
|
||||
using namespace Exiv2;
|
||||
using ::testing::StartsWith;
|
||||
@ -161,3 +162,12 @@ TEST(IptcDataSets, dataSet_throwWithNonExistingRecordId)
|
||||
ASSERT_STREQ("Invalid dataset name `ModelVersion'", e.what());
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------
|
||||
|
||||
TEST(IptcDataSets, dataSetLists_printDatasetsIntoOstream)
|
||||
{
|
||||
std::ostringstream stream;
|
||||
ASSERT_NO_THROW(IptcDataSets::dataSetList(stream));
|
||||
ASSERT_FALSE(stream.str().empty());
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user