239 {
240 std::vector<std::string> commentStrings;
243 pushComment(commentStrings,
"have some",
"spaces in both");
244
245 std::string longKey(PNG_KEYWORD_MAX_LENGTH, 'x');
246#ifdef SK_DEBUG
247 commentStrings.push_back(longKey);
248#else
249
250 commentStrings.push_back(longKey + "x");
251#endif
252 commentStrings.push_back("");
253
254 std::vector<const char*> commentPointers;
255 std::vector<size_t> commentSizes;
256 for(auto& str : commentStrings) {
257 commentPointers.push_back(str.c_str());
258 commentSizes.push_back(str.length() + 1);
259 }
260
262 commentSizes.data(), commentStrings.size());
263
264
268
269 std::vector<char>
output(
dst.bytesWritten());
271
272
273
274
275 const char kExpected1[] =
276 "\x00\x00\x00\x08tEXtkey\x00text\x9e\xe7\x66\x51";
277 const char kExpected2[] =
278 "\x00\x00\x00\x0etEXttest\x00something\x29\xba\xef\xac";
279 const char kExpected3[] =
280 "\x00\x00\x00\x18tEXthave some\x00spaces in both\x8d\x69\x34\x2d";
281 std::string longKeyRecord = "tEXt" + longKey;
282 std::string tooLongRecord = "tExt" + longKey + "x";
283
284 auto search1 = std::search(
output.begin(),
output.end(),
285 kExpected1, kExpected1 + sizeof(kExpected1));
286 auto search2 = std::search(
output.begin(),
output.end(),
287 kExpected2, kExpected2 + sizeof(kExpected2));
288 auto search3 = std::search(
output.begin(),
output.end(),
289 kExpected3, kExpected3 + sizeof(kExpected3));
290 auto search4 = std::search(
output.begin(),
output.end(),
291 longKeyRecord.begin(), longKeyRecord.end());
292 auto search5 = std::search(
output.begin(),
output.end(),
293 tooLongRecord.begin(), tooLongRecord.end());
294
300
301}
static void pushComment(std::vector< std::string > &comments, const char *keyword, const char *text)
static sk_sp< SkDataTable > MakeCopyArrays(const void *const *ptrs, const size_t sizes[], int count)