MCPcopy Create free account
hub / github.com/Exiv2/exiv2 / testCase

Function testCase

samples/write-test.cpp:113–151  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

111
112// *****************************************************************************
113void testCase(const std::string& file1, const std::string& file2, const std::string& thumb, const std::string& key,
114 const std::string& value) {
115 ExifKey ek(key);
116
117 // Open first image
118 auto image1 = ImageFactory::open(file1);
119
120 // Load existing metadata
121 std::cerr << "---> Reading file " << file1 << "\n";
122 image1->readMetadata();
123
124 Exiv2::ExifData& ed1 = image1->exifData();
125 std::cerr << "---> Modifying Exif data\n";
126 auto pos = ed1.findKey(ek);
127 if (pos == ed1.end()) {
128 throw Error(ErrorCode::kerErrorMessage, "Metadatum with key = " + ek.key() + " not found");
129 }
130 pos->setValue(value);
131
132 // Open second image
133 auto image2 = ImageFactory::open(file2);
134
135 image2->setExifData(image1->exifData());
136
137 std::cerr << "---> Writing Exif data to file " << file2 << "\n";
138 image2->writeMetadata();
139
140 std::cerr << "---> Reading file " << file2 << "\n";
141 image2->readMetadata();
142
143 Exiv2::ExifData& ed2 = image2->exifData();
144 exifPrint(ed2);
145
146 std::cerr << "---> Writing Exif thumbnail to file " << thumb << ".*\n";
147 ExifThumbC et2(ed2);
148 auto s = et2.writeFile(thumb);
149 if (s == 0)
150 std::cerr << "---> Failed to write to file " << thumb << ".*\n";
151}
152
153// *****************************************************************************
154

Callers 1

mainFunction · 0.85

Calls 10

ErrorFunction · 0.85
exifPrintFunction · 0.85
readMetadataMethod · 0.45
findKeyMethod · 0.45
endMethod · 0.45
keyMethod · 0.45
setValueMethod · 0.45
setExifDataMethod · 0.45
writeMetadataMethod · 0.45
writeFileMethod · 0.45

Tested by

no test coverage detected