Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
cpdf_object_unittest.cpp
Go to the documentation of this file.
1// Copyright 2016 The PDFium Authors
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "core/fpdfapi/parser/cpdf_object.h"
6
7#include <stdint.h>
8
9#include <memory>
10#include <string>
11#include <utility>
12#include <vector>
13
14#include "constants/stream_dict_common.h"
15#include "core/fpdfapi/parser/cpdf_array.h"
16#include "core/fpdfapi/parser/cpdf_boolean.h"
17#include "core/fpdfapi/parser/cpdf_dictionary.h"
18#include "core/fpdfapi/parser/cpdf_indirect_object_holder.h"
19#include "core/fpdfapi/parser/cpdf_name.h"
20#include "core/fpdfapi/parser/cpdf_null.h"
21#include "core/fpdfapi/parser/cpdf_number.h"
22#include "core/fpdfapi/parser/cpdf_reference.h"
23#include "core/fpdfapi/parser/cpdf_stream.h"
24#include "core/fpdfapi/parser/cpdf_stream_acc.h"
25#include "core/fpdfapi/parser/cpdf_string.h"
26#include "core/fxcrt/data_vector.h"
27#include "core/fxcrt/fx_memory_wrappers.h"
28#include "testing/gtest/include/gtest/gtest.h"
29
30namespace {
31
32void TestArrayAccessors(const CPDF_Array* arr,
33 size_t index,
34 const char* str_val,
35 const char* const_str_val,
36 int int_val,
37 float float_val,
38 CPDF_Array* arr_val,
39 CPDF_Dictionary* dict_val,
40 CPDF_Stream* stream_val) {
41 EXPECT_STREQ(str_val, arr->GetByteStringAt(index).c_str());
42 EXPECT_EQ(int_val, arr->GetIntegerAt(index));
43 EXPECT_EQ(float_val, arr->GetFloatAt(index));
44 EXPECT_EQ(arr_val, arr->GetArrayAt(index));
45 EXPECT_EQ(dict_val, arr->GetDictAt(index));
46 EXPECT_EQ(stream_val, arr->GetStreamAt(index));
47}
48
49} // namespace
50
51class PDFObjectsTest : public testing::Test {
52 public:
53 void SetUp() override {
54 // Initialize different kinds of objects.
55 // Boolean objects.
56 auto boolean_false_obj = pdfium::MakeRetain<CPDF_Boolean>(false);
57 auto boolean_true_obj = pdfium::MakeRetain<CPDF_Boolean>(true);
58 // Number objects.
59 auto number_int_obj = pdfium::MakeRetain<CPDF_Number>(1245);
60 auto number_float_obj = pdfium::MakeRetain<CPDF_Number>(9.00345f);
61 // String objects.
62 auto str_reg_obj =
63 pdfium::MakeRetain<CPDF_String>(nullptr, L"A simple test");
64 auto str_spec_obj = pdfium::MakeRetain<CPDF_String>(nullptr, L"\t\n");
65 // Name object.
66 auto name_obj = pdfium::MakeRetain<CPDF_Name>(nullptr, "space");
67 // Array object.
68 m_ArrayObj = pdfium::MakeRetain<CPDF_Array>();
69 m_ArrayObj->InsertNewAt<CPDF_Number>(0, 8902);
70 m_ArrayObj->InsertNewAt<CPDF_Name>(1, "address");
71 // Dictionary object.
72 m_DictObj = pdfium::MakeRetain<CPDF_Dictionary>();
73 m_DictObj->SetNewFor<CPDF_Boolean>("bool", false);
74 m_DictObj->SetNewFor<CPDF_Number>("num", 0.23f);
75 // Stream object.
76 static constexpr char kContents[] = "abcdefghijklmnopqrstuvwxyz";
77 auto pNewDict = pdfium::MakeRetain<CPDF_Dictionary>();
78 m_StreamDictObj = pNewDict;
79 m_StreamDictObj->SetNewFor<CPDF_String>("key1", L" test dict");
80 m_StreamDictObj->SetNewFor<CPDF_Number>("key2", -1);
81 auto stream_obj = pdfium::MakeRetain<CPDF_Stream>(
82 DataVector<uint8_t>(std::begin(kContents), std::end(kContents)),
83 std::move(pNewDict));
84 // Null Object.
85 auto null_obj = pdfium::MakeRetain<CPDF_Null>();
86 // All direct objects.
87 CPDF_Object* objs[] = {
88 boolean_false_obj.Get(), boolean_true_obj.Get(), number_int_obj.Get(),
89 number_float_obj.Get(), str_reg_obj.Get(), str_spec_obj.Get(),
90 name_obj.Get(), m_ArrayObj.Get(), m_DictObj.Get(),
91 stream_obj.Get(), null_obj.Get()};
92 m_DirectObjTypes = {
93 CPDF_Object::kBoolean, CPDF_Object::kBoolean, CPDF_Object::kNumber,
94 CPDF_Object::kNumber, CPDF_Object::kString, CPDF_Object::kString,
95 CPDF_Object::kName, CPDF_Object::kArray, CPDF_Object::kDictionary,
96 CPDF_Object::kStream, CPDF_Object::kNullobj};
97 for (size_t i = 0; i < std::size(objs); ++i)
98 m_DirectObjs.emplace_back(objs[i]);
99
100 // Indirect references to indirect objects.
101 m_ObjHolder = std::make_unique<CPDF_IndirectObjectHolder>();
102 m_IndirectObjNums = {
103 m_ObjHolder->AddIndirectObject(boolean_true_obj->Clone()),
104 m_ObjHolder->AddIndirectObject(number_int_obj->Clone()),
105 m_ObjHolder->AddIndirectObject(str_spec_obj->Clone()),
106 m_ObjHolder->AddIndirectObject(name_obj->Clone()),
107 m_ObjHolder->AddIndirectObject(m_ArrayObj->Clone()),
108 m_ObjHolder->AddIndirectObject(m_DictObj->Clone()),
109 m_ObjHolder->AddIndirectObject(stream_obj->Clone())};
110 for (uint32_t objnum : m_IndirectObjNums) {
111 m_RefObjs.emplace_back(
112 pdfium::MakeRetain<CPDF_Reference>(m_ObjHolder.get(), objnum));
113 }
114 }
115
116 bool Equal(const CPDF_Object* obj1, const CPDF_Object* obj2) {
117 if (obj1 == obj2)
118 return true;
119 if (!obj1 || !obj2 || obj1->GetType() != obj2->GetType())
120 return false;
121 switch (obj1->GetType()) {
123 return obj1->GetInteger() == obj2->GetInteger();
129 return obj1->GetString() == obj2->GetString();
130 case CPDF_Object::kArray: {
131 const CPDF_Array* array1 = obj1->AsArray();
132 const CPDF_Array* array2 = obj2->AsArray();
133 if (array1->size() != array2->size())
134 return false;
135 for (size_t i = 0; i < array1->size(); ++i) {
136 if (!Equal(array1->GetObjectAt(i).Get(),
137 array2->GetObjectAt(i).Get())) {
138 return false;
139 }
140 }
141 return true;
142 }
144 const CPDF_Dictionary* dict1 = obj1->AsDictionary();
145 const CPDF_Dictionary* dict2 = obj2->AsDictionary();
146 if (dict1->size() != dict2->size())
147 return false;
148 CPDF_DictionaryLocker locker1(dict1);
149 for (const auto& item : locker1) {
150 if (!Equal(item.second.Get(), dict2->GetObjectFor(item.first).Get()))
151 return false;
152 }
153 return true;
154 }
156 return true;
158 RetainPtr<const CPDF_Stream> stream1(obj1->AsStream());
159 RetainPtr<const CPDF_Stream> stream2(obj2->AsStream());
160 if (!stream1->GetDict() && !stream2->GetDict())
161 return true;
162 // Compare dictionaries.
163 if (!Equal(stream1->GetDict().Get(), stream2->GetDict().Get()))
164 return false;
165
166 auto streamAcc1 =
167 pdfium::MakeRetain<CPDF_StreamAcc>(std::move(stream1));
168 streamAcc1->LoadAllDataRaw();
169 auto streamAcc2 =
170 pdfium::MakeRetain<CPDF_StreamAcc>(std::move(stream2));
171 streamAcc2->LoadAllDataRaw();
172 pdfium::span<const uint8_t> span1 = streamAcc1->GetSpan();
173 pdfium::span<const uint8_t> span2 = streamAcc2->GetSpan();
174
175 // Compare sizes.
176 if (span1.size() != span2.size())
177 return false;
178
179 return memcmp(span1.data(), span2.data(), span2.size()) == 0;
180 }
184 }
185 return false;
186 }
187
188 protected:
189 // m_ObjHolder needs to be declared first and destructed last since it also
190 // refers to some objects in m_DirectObjs.
195 RetainPtr<CPDF_Dictionary> m_DictObj;
196 RetainPtr<CPDF_Dictionary> m_StreamDictObj;
199};
200
202 const char* const direct_obj_results[] = {
203 "false", "true", "1245", "9.00345", "A simple test", "\t\n", "space",
204 "", "", "", ""};
205 // Check for direct objects.
206 for (size_t i = 0; i < m_DirectObjs.size(); ++i)
207 EXPECT_STREQ(direct_obj_results[i], m_DirectObjs[i]->GetString().c_str());
208
209 // Check indirect references.
210 const char* const indirect_obj_results[] = {"true", "1245", "\t\n", "space",
211 "", "", ""};
212 for (size_t i = 0; i < m_RefObjs.size(); ++i) {
213 EXPECT_STREQ(indirect_obj_results[i], m_RefObjs[i]->GetString().c_str());
214 }
215}
216
218 const wchar_t* const direct_obj_results[] = {
219 L"", L"", L"", L"", L"A simple test",
220 L"\t\n", L"space", L"", L"", L"abcdefghijklmnopqrstuvwxyz",
221 L""};
222 // Check for direct objects.
223 for (size_t i = 0; i < m_DirectObjs.size(); ++i) {
224 EXPECT_STREQ(direct_obj_results[i],
225 m_DirectObjs[i]->GetUnicodeText().c_str());
226 }
227
228 // Check indirect references.
229 for (const auto& it : m_RefObjs)
230 EXPECT_STREQ(L"", it->GetUnicodeText().c_str());
231}
232
234 const float direct_obj_results[] = {0, 0, 1245, 9.00345f, 0, 0,
235 0, 0, 0, 0, 0};
236 // Check for direct objects.
237 for (size_t i = 0; i < m_DirectObjs.size(); ++i)
238 EXPECT_EQ(direct_obj_results[i], m_DirectObjs[i]->GetNumber());
239
240 // Check indirect references.
241 const float indirect_obj_results[] = {0, 1245, 0, 0, 0, 0, 0};
242 for (size_t i = 0; i < m_RefObjs.size(); ++i)
243 EXPECT_EQ(indirect_obj_results[i], m_RefObjs[i]->GetNumber());
244}
245
247 const int direct_obj_results[] = {0, 1, 1245, 9, 0, 0, 0, 0, 0, 0, 0};
248 // Check for direct objects.
249 for (size_t i = 0; i < m_DirectObjs.size(); ++i)
250 EXPECT_EQ(direct_obj_results[i], m_DirectObjs[i]->GetInteger());
251
252 // Check indirect references.
253 const int indirect_obj_results[] = {1, 1245, 0, 0, 0, 0, 0};
254 for (size_t i = 0; i < m_RefObjs.size(); ++i)
255 EXPECT_EQ(indirect_obj_results[i], m_RefObjs[i]->GetInteger());
256}
257
259 const CPDF_Dictionary* const direct_obj_results[] = {
260 nullptr, nullptr, nullptr, nullptr, nullptr,
261 nullptr, nullptr, nullptr, m_DictObj.Get(), m_StreamDictObj.Get(),
262 nullptr};
263 // Check for direct objects.
264 for (size_t i = 0; i < m_DirectObjs.size(); ++i)
265 EXPECT_EQ(direct_obj_results[i], m_DirectObjs[i]->GetDict());
266
267 // Check indirect references.
268 const CPDF_Dictionary* const indirect_obj_results[] = {nullptr,
269 nullptr,
270 nullptr,
271 nullptr,
272 nullptr,
273 m_DictObj.Get(),
274 m_StreamDictObj.Get()};
275 for (size_t i = 0; i < m_RefObjs.size(); ++i)
276 EXPECT_TRUE(Equal(indirect_obj_results[i], m_RefObjs[i]->GetDict().Get()));
277}
278
280 m_DictObj->SetNewFor<CPDF_String>("string", "ium", false);
281 m_DictObj->SetNewFor<CPDF_Name>("name", "Pdf");
282
283 EXPECT_STREQ("", m_DictObj->GetNameFor("invalid").c_str());
284 EXPECT_STREQ("", m_DictObj->GetNameFor("bool").c_str());
285 EXPECT_STREQ("", m_DictObj->GetNameFor("num").c_str());
286 EXPECT_STREQ("", m_DictObj->GetNameFor("string").c_str());
287 EXPECT_STREQ("Pdf", m_DictObj->GetNameFor("name").c_str());
288
289 EXPECT_STREQ("", m_DictObj->GetByteStringFor("invalid").c_str());
290 EXPECT_STREQ("false", m_DictObj->GetByteStringFor("bool").c_str());
291 EXPECT_STREQ("0.23", m_DictObj->GetByteStringFor("num").c_str());
292 EXPECT_STREQ("ium", m_DictObj->GetByteStringFor("string").c_str());
293 EXPECT_STREQ("Pdf", m_DictObj->GetByteStringFor("name").c_str());
294}
295
297 const CPDF_Array* const direct_obj_results[] = {
298 nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
299 nullptr, m_ArrayObj.Get(), nullptr, nullptr, nullptr};
300 // Check for direct objects.
301 for (size_t i = 0; i < m_DirectObjs.size(); ++i)
302 EXPECT_EQ(direct_obj_results[i], m_DirectObjs[i]->AsArray());
303
304 // Check indirect references.
305 for (const auto& it : m_RefObjs)
306 EXPECT_FALSE(it->AsArray());
307}
308
310 // Check for direct objects.
311 for (size_t i = 0; i < m_DirectObjs.size(); ++i) {
312 RetainPtr<CPDF_Object> obj = m_DirectObjs[i]->Clone();
313 EXPECT_TRUE(Equal(m_DirectObjs[i].Get(), obj.Get()));
314 }
315
316 // Check indirect references.
317 for (const auto& it : m_RefObjs) {
318 RetainPtr<CPDF_Object> obj = it->Clone();
319 EXPECT_TRUE(Equal(it.Get(), obj.Get()));
320 }
321}
322
324 // Check for direct objects.
325 for (size_t i = 0; i < m_DirectObjs.size(); ++i)
326 EXPECT_EQ(m_DirectObjTypes[i], m_DirectObjs[i]->GetType());
327
328 // Check indirect references.
329 for (const auto& it : m_RefObjs)
330 EXPECT_EQ(CPDF_Object::kReference, it->GetType());
331}
332
334 // Check for direct objects.
335 for (size_t i = 0; i < m_DirectObjs.size(); ++i)
336 EXPECT_EQ(m_DirectObjs[i].Get(), m_DirectObjs[i]->GetDirect());
337
338 // Check indirect references.
339 for (size_t i = 0; i < m_RefObjs.size(); ++i)
340 EXPECT_EQ(m_IndirectObjNums[i], m_RefObjs[i]->GetDirect()->GetObjNum());
341}
342
344 // Check for direct objects.
345 const char* const set_values[] = {"true", "fake", "3.125f", "097",
346 "changed", "", "NewName"};
347 const char* const expected[] = {"true", "false", "3.125", "97",
348 "changed", "", "NewName"};
349 for (size_t i = 0; i < std::size(set_values); ++i) {
350 m_DirectObjs[i]->SetString(set_values[i]);
351 EXPECT_STREQ(expected[i], m_DirectObjs[i]->GetString().c_str());
352 }
353}
354
356 // Check for direct objects.
357 for (size_t i = 0; i < m_DirectObjs.size(); ++i) {
358 if (m_DirectObjTypes[i] == CPDF_Object::kArray) {
359 EXPECT_TRUE(m_DirectObjs[i]->IsArray());
360 EXPECT_EQ(m_DirectObjs[i].Get(), m_DirectObjs[i]->AsArray());
361 } else {
362 EXPECT_FALSE(m_DirectObjs[i]->IsArray());
363 EXPECT_FALSE(m_DirectObjs[i]->AsArray());
364 }
365
366 if (m_DirectObjTypes[i] == CPDF_Object::kBoolean) {
367 EXPECT_TRUE(m_DirectObjs[i]->IsBoolean());
368 EXPECT_EQ(m_DirectObjs[i].Get(), m_DirectObjs[i]->AsBoolean());
369 } else {
370 EXPECT_FALSE(m_DirectObjs[i]->IsBoolean());
371 EXPECT_FALSE(m_DirectObjs[i]->AsBoolean());
372 }
373
374 if (m_DirectObjTypes[i] == CPDF_Object::kName) {
375 EXPECT_TRUE(m_DirectObjs[i]->IsName());
376 EXPECT_EQ(m_DirectObjs[i].Get(), m_DirectObjs[i]->AsName());
377 } else {
378 EXPECT_FALSE(m_DirectObjs[i]->IsName());
379 EXPECT_FALSE(m_DirectObjs[i]->AsName());
380 }
381
382 if (m_DirectObjTypes[i] == CPDF_Object::kNumber) {
383 EXPECT_TRUE(m_DirectObjs[i]->IsNumber());
384 EXPECT_EQ(m_DirectObjs[i].Get(), m_DirectObjs[i]->AsNumber());
385 } else {
386 EXPECT_FALSE(m_DirectObjs[i]->IsNumber());
387 EXPECT_FALSE(m_DirectObjs[i]->AsNumber());
388 }
389
390 if (m_DirectObjTypes[i] == CPDF_Object::kString) {
391 EXPECT_TRUE(m_DirectObjs[i]->IsString());
392 EXPECT_EQ(m_DirectObjs[i].Get(), m_DirectObjs[i]->AsString());
393 } else {
394 EXPECT_FALSE(m_DirectObjs[i]->IsString());
395 EXPECT_FALSE(m_DirectObjs[i]->AsString());
396 }
397
398 if (m_DirectObjTypes[i] == CPDF_Object::kDictionary) {
399 EXPECT_TRUE(m_DirectObjs[i]->IsDictionary());
400 EXPECT_EQ(m_DirectObjs[i].Get(), m_DirectObjs[i]->AsDictionary());
401 } else {
402 EXPECT_FALSE(m_DirectObjs[i]->IsDictionary());
403 EXPECT_FALSE(m_DirectObjs[i]->AsDictionary());
404 }
405
406 if (m_DirectObjTypes[i] == CPDF_Object::kStream) {
407 EXPECT_TRUE(m_DirectObjs[i]->IsStream());
408 EXPECT_EQ(m_DirectObjs[i].Get(), m_DirectObjs[i]->AsStream());
409 } else {
410 EXPECT_FALSE(m_DirectObjs[i]->IsStream());
411 EXPECT_FALSE(m_DirectObjs[i]->AsStream());
412 }
413
414 EXPECT_FALSE(m_DirectObjs[i]->IsReference());
415 EXPECT_FALSE(m_DirectObjs[i]->AsReference());
416 }
417 // Check indirect references.
418 for (size_t i = 0; i < m_RefObjs.size(); ++i) {
419 EXPECT_TRUE(m_RefObjs[i]->IsReference());
420 EXPECT_EQ(m_RefObjs[i].Get(), m_RefObjs[i]->AsReference());
421 }
422}
423
425 auto original_obj = pdfium::MakeRetain<CPDF_Null>();
426 original_obj->SetObjNum(42);
427 ASSERT_FALSE(original_obj->IsInline());
428
429 auto ref_obj = original_obj->MakeReference(m_ObjHolder.get());
430
431 ASSERT_TRUE(ref_obj->IsReference());
432 EXPECT_EQ(original_obj->GetObjNum(),
433 ToReference(ref_obj.Get())->GetRefObjNum());
434}
435
437 std::set<uint64_t> key_set;
438
439 // Check all direct objects inserted without collision.
440 for (const auto& direct : m_DirectObjs) {
441 EXPECT_TRUE(key_set.insert(direct->KeyForCache()).second);
442 }
443 // Check indirect objects inserted without collision.
444 for (const auto& pair : *m_ObjHolder) {
445 EXPECT_TRUE(key_set.insert(pair.second->KeyForCache()).second);
446 }
447
448 // Check all expected objects counted.
449 EXPECT_EQ(18u, key_set.size());
450}
451
453 float elems[][6] = {{0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f},
454 {1, 2, 3, 4, 5, 6},
455 {2.3f, 4.05f, 3, -2, -3, 0.0f},
456 {0.05f, 0.1f, 0.56f, 0.67f, 1.34f, 99.9f}};
457 for (size_t i = 0; i < std::size(elems); ++i) {
458 auto arr = pdfium::MakeRetain<CPDF_Array>();
459 CFX_Matrix matrix(elems[i][0], elems[i][1], elems[i][2], elems[i][3],
460 elems[i][4], elems[i][5]);
461 for (size_t j = 0; j < 6; ++j)
462 arr->AppendNew<CPDF_Number>(elems[i][j]);
463 CFX_Matrix arr_matrix = arr->GetMatrix();
464 EXPECT_EQ(matrix.a, arr_matrix.a);
465 EXPECT_EQ(matrix.b, arr_matrix.b);
466 EXPECT_EQ(matrix.c, arr_matrix.c);
467 EXPECT_EQ(matrix.d, arr_matrix.d);
468 EXPECT_EQ(matrix.e, arr_matrix.e);
469 EXPECT_EQ(matrix.f, arr_matrix.f);
470 }
471}
472
474 float elems[][4] = {{0.0f, 0.0f, 0.0f, 0.0f},
475 {1, 2, 5, 6},
476 {2.3f, 4.05f, -3, 0.0f},
477 {0.05f, 0.1f, 1.34f, 99.9f}};
478 for (size_t i = 0; i < std::size(elems); ++i) {
479 auto arr = pdfium::MakeRetain<CPDF_Array>();
480 CFX_FloatRect rect(elems[i][0], elems[i][1], elems[i][2], elems[i][3]);
481 for (size_t j = 0; j < 4; ++j)
482 arr->AppendNew<CPDF_Number>(elems[i][j]);
483 CFX_FloatRect arr_rect = arr->GetRect();
484 EXPECT_EQ(rect.left, arr_rect.left);
485 EXPECT_EQ(rect.right, arr_rect.right);
486 EXPECT_EQ(rect.bottom, arr_rect.bottom);
487 EXPECT_EQ(rect.top, arr_rect.top);
488 }
489}
490
492 {
493 // Boolean array.
494 const bool vals[] = {true, false, false, true, true};
495 auto arr = pdfium::MakeRetain<CPDF_Array>();
496 for (size_t i = 0; i < std::size(vals); ++i)
497 arr->InsertNewAt<CPDF_Boolean>(i, vals[i]);
498 for (size_t i = 0; i < std::size(vals); ++i) {
499 TestArrayAccessors(arr.Get(), i, // Array and index.
500 vals[i] ? "true" : "false", // String value.
501 nullptr, // Const string value.
502 vals[i] ? 1 : 0, // Integer value.
503 0, // Float value.
504 nullptr, // Array value.
505 nullptr, // Dictionary value.
506 nullptr); // Stream value.
507 }
508 }
509 {
510 // Integer array.
511 const int vals[] = {10, 0, -345, 2089345456, -1000000000, 567, 93658767};
512 auto arr = pdfium::MakeRetain<CPDF_Array>();
513 for (size_t i = 0; i < std::size(vals); ++i)
514 arr->InsertNewAt<CPDF_Number>(i, vals[i]);
515 for (size_t i = 0; i < std::size(vals); ++i) {
516 char buf[33];
517 TestArrayAccessors(arr.Get(), i, // Array and index.
518 FXSYS_itoa(vals[i], buf, 10), // String value.
519 nullptr, // Const string value.
520 vals[i], // Integer value.
521 vals[i], // Float value.
522 nullptr, // Array value.
523 nullptr, // Dictionary value.
524 nullptr); // Stream value.
525 }
526 }
527 {
528 // Float array.
529 const float vals[] = {0.0f, 0, 10, 10.0f, 0.0345f,
530 897.34f, -2.5f, -1.0f, -345.0f, -0.0f};
531 const char* const expected_str[] = {
532 "0", "0", "10", "10", "0.0345", "897.34", "-2.5", "-1", "-345", "0"};
533 auto arr = pdfium::MakeRetain<CPDF_Array>();
534 for (size_t i = 0; i < std::size(vals); ++i)
535 arr->InsertNewAt<CPDF_Number>(i, vals[i]);
536 for (size_t i = 0; i < std::size(vals); ++i) {
537 TestArrayAccessors(arr.Get(), i, // Array and index.
538 expected_str[i], // String value.
539 nullptr, // Const string value.
540 vals[i], // Integer value.
541 vals[i], // Float value.
542 nullptr, // Array value.
543 nullptr, // Dictionary value.
544 nullptr); // Stream value.
545 }
546 }
547 {
548 // String and name array
549 const char* const vals[] = {"this", "adsde$%^", "\r\t", "\"012",
550 ".", "EYREW", "It is a joke :)"};
551 auto string_array = pdfium::MakeRetain<CPDF_Array>();
552 auto name_array = pdfium::MakeRetain<CPDF_Array>();
553 for (size_t i = 0; i < std::size(vals); ++i) {
554 string_array->InsertNewAt<CPDF_String>(i, vals[i], false);
555 name_array->InsertNewAt<CPDF_Name>(i, vals[i]);
556 }
557 for (size_t i = 0; i < std::size(vals); ++i) {
558 TestArrayAccessors(string_array.Get(), i, // Array and index.
559 vals[i], // String value.
560 vals[i], // Const string value.
561 0, // Integer value.
562 0, // Float value.
563 nullptr, // Array value.
564 nullptr, // Dictionary value.
565 nullptr); // Stream value.
566 TestArrayAccessors(name_array.Get(), i, // Array and index.
567 vals[i], // String value.
568 vals[i], // Const string value.
569 0, // Integer value.
570 0, // Float value.
571 nullptr, // Array value.
572 nullptr, // Dictionary value.
573 nullptr); // Stream value.
574 }
575 }
576 {
577 // Null element array.
578 auto arr = pdfium::MakeRetain<CPDF_Array>();
579 for (size_t i = 0; i < 3; ++i)
580 arr->InsertNewAt<CPDF_Null>(i);
581 for (size_t i = 0; i < 3; ++i) {
582 TestArrayAccessors(arr.Get(), i, // Array and index.
583 "", // String value.
584 nullptr, // Const string value.
585 0, // Integer value.
586 0, // Float value.
587 nullptr, // Array value.
588 nullptr, // Dictionary value.
589 nullptr); // Stream value.
590 }
591 }
592 {
593 // Array of array.
594 RetainPtr<CPDF_Array> vals[3];
595 auto arr = pdfium::MakeRetain<CPDF_Array>();
596 for (size_t i = 0; i < 3; ++i) {
597 vals[i] = arr->AppendNew<CPDF_Array>();
598 for (size_t j = 0; j < 3; ++j) {
599 int value = j + 100;
600 vals[i]->InsertNewAt<CPDF_Number>(j, value);
601 }
602 }
603 for (size_t i = 0; i < 3; ++i) {
604 TestArrayAccessors(arr.Get(), i, // Array and index.
605 "", // String value.
606 nullptr, // Const string value.
607 0, // Integer value.
608 0, // Float value.
609 vals[i].Get(), // Array value.
610 nullptr, // Dictionary value.
611 nullptr); // Stream value.
612 }
613 }
614 {
615 // Dictionary array.
616 RetainPtr<CPDF_Dictionary> vals[3];
617 auto arr = pdfium::MakeRetain<CPDF_Array>();
618 for (size_t i = 0; i < 3; ++i) {
619 vals[i] = arr->AppendNew<CPDF_Dictionary>();
620 for (size_t j = 0; j < 3; ++j) {
621 std::string key("key");
622 char buf[33];
623 key.append(FXSYS_itoa(j, buf, 10));
624 int value = j + 200;
625 vals[i]->SetNewFor<CPDF_Number>(key.c_str(), value);
626 }
627 }
628 for (size_t i = 0; i < 3; ++i) {
629 TestArrayAccessors(arr.Get(), i, // Array and index.
630 "", // String value.
631 nullptr, // Const string value.
632 0, // Integer value.
633 0, // Float value.
634 nullptr, // Array value.
635 vals[i].Get(), // Dictionary value.
636 nullptr); // Stream value.
637 }
638 }
639 {
640 // Stream array.
641 RetainPtr<CPDF_Dictionary> vals[3];
642 RetainPtr<CPDF_Stream> stream_vals[3];
643 auto arr = pdfium::MakeRetain<CPDF_Array>();
644 for (size_t i = 0; i < 3; ++i) {
645 vals[i] = pdfium::MakeRetain<CPDF_Dictionary>();
646 for (size_t j = 0; j < 3; ++j) {
647 std::string key("key");
648 char buf[33];
649 key.append(FXSYS_itoa(j, buf, 10));
650 int value = j + 200;
651 vals[i]->SetNewFor<CPDF_Number>(key.c_str(), value);
652 }
653 static constexpr uint8_t kContents[] = "content: this is a stream";
654 stream_vals[i] = arr->AppendNew<CPDF_Stream>(
655 DataVector<uint8_t>(std::begin(kContents), std::end(kContents)),
656 vals[i]);
657 }
658 for (size_t i = 0; i < 3; ++i) {
659 TestArrayAccessors(arr.Get(), i, // Array and index.
660 "", // String value.
661 nullptr, // Const string value.
662 0, // Integer value.
663 0, // Float value.
664 nullptr, // Array value.
665 vals[i].Get(), // Dictionary value.
666 stream_vals[i].Get()); // Stream value.
667 }
668 }
669 {
670 // Mixed array.
671 auto arr = pdfium::MakeRetain<CPDF_Array>();
672 arr->InsertNewAt<CPDF_Boolean>(0, true);
673 arr->InsertNewAt<CPDF_Boolean>(1, false);
674 arr->InsertNewAt<CPDF_Number>(2, 0);
675 arr->InsertNewAt<CPDF_Number>(3, -1234);
676 arr->InsertNewAt<CPDF_Number>(4, 2345.0f);
677 arr->InsertNewAt<CPDF_Number>(5, 0.05f);
678 arr->InsertNewAt<CPDF_String>(6, "", false);
679 arr->InsertNewAt<CPDF_String>(7, "It is a test!", false);
680 arr->InsertNewAt<CPDF_Name>(8, "NAME");
681 arr->InsertNewAt<CPDF_Name>(9, "test");
682 arr->InsertNewAt<CPDF_Null>(10);
683
684 auto arr_val = arr->InsertNewAt<CPDF_Array>(11);
685 arr_val->AppendNew<CPDF_Number>(1);
686 arr_val->AppendNew<CPDF_Number>(2);
687
688 auto dict_val = arr->InsertNewAt<CPDF_Dictionary>(12);
689 dict_val->SetNewFor<CPDF_String>("key1", "Linda", false);
690 dict_val->SetNewFor<CPDF_String>("key2", "Zoe", false);
691
692 auto stream_dict = pdfium::MakeRetain<CPDF_Dictionary>();
693 stream_dict->SetNewFor<CPDF_String>("key1", "John", false);
694 stream_dict->SetNewFor<CPDF_String>("key2", "King", false);
695 static constexpr uint8_t kData[] = "A stream for test";
696 // The data buffer will be owned by stream object, so it needs to be
697 // dynamically allocated.
698 CPDF_Stream* stream_val = arr->InsertNewAt<CPDF_Stream>(
699 13, DataVector<uint8_t>(std::begin(kData), std::end(kData)),
700 stream_dict);
701 const char* const expected_str[] = {
702 "true", "false", "0", "-1234", "2345", "0.05", "",
703 "It is a test!", "NAME", "test", "", "", "", ""};
704 const int expected_int[] = {1, 0, 0, -1234, 2345, 0, 0,
705 0, 0, 0, 0, 0, 0, 0};
706 const float expected_float[] = {0, 0, 0, -1234, 2345, 0.05f, 0,
707 0, 0, 0, 0, 0, 0, 0};
708 for (size_t i = 0; i < arr->size(); ++i) {
709 EXPECT_STREQ(expected_str[i], arr->GetByteStringAt(i).c_str());
710 EXPECT_EQ(expected_int[i], arr->GetIntegerAt(i));
711 EXPECT_EQ(expected_float[i], arr->GetFloatAt(i));
712 if (i == 11)
713 EXPECT_EQ(arr_val, arr->GetArrayAt(i));
714 else
715 EXPECT_FALSE(arr->GetArrayAt(i));
716 if (i == 13) {
717 EXPECT_EQ(stream_dict, arr->GetDictAt(i));
718 EXPECT_EQ(stream_val, arr->GetStreamAt(i));
719 } else {
720 EXPECT_FALSE(arr->GetStreamAt(i));
721 if (i == 12)
722 EXPECT_EQ(dict_val, arr->GetDictAt(i));
723 else
724 EXPECT_FALSE(arr->GetDictAt(i));
725 }
726 }
727 }
728}
729
731 float vals[] = {1.0f, -1.0f, 0, 0.456734f,
732 12345.54321f, 0.5f, 1000, 0.000045f};
733 auto arr = pdfium::MakeRetain<CPDF_Array>();
734 for (size_t i = 0; i < std::size(vals); ++i)
735 arr->AppendNew<CPDF_Number>(vals[i]);
736 for (size_t i = 0; i < std::size(vals); ++i) {
737 EXPECT_EQ(CPDF_Object::kNumber, arr->GetObjectAt(i)->GetType());
738 EXPECT_EQ(vals[i], arr->GetObjectAt(i)->GetNumber());
739 }
740}
741
743 int vals[] = {0, 1, 934435456, 876, 10000, -1, -24354656, -100};
744 auto arr = pdfium::MakeRetain<CPDF_Array>();
745 for (size_t i = 0; i < std::size(vals); ++i)
746 arr->AppendNew<CPDF_Number>(vals[i]);
747 for (size_t i = 0; i < std::size(vals); ++i) {
748 EXPECT_EQ(CPDF_Object::kNumber, arr->GetObjectAt(i)->GetType());
749 EXPECT_EQ(vals[i], arr->GetObjectAt(i)->GetNumber());
750 }
751}
752
754 static constexpr const char* kVals[] = {
755 "", "a", "ehjhRIOYTTFdfcdnv", "122323",
756 "$#%^&**", " ", "This is a test.\r\n"};
757 auto string_array = pdfium::MakeRetain<CPDF_Array>();
758 auto name_array = pdfium::MakeRetain<CPDF_Array>();
759 for (const char* val : kVals) {
760 string_array->AppendNew<CPDF_String>(val, false);
761 name_array->AppendNew<CPDF_Name>(val);
762 }
763 for (size_t i = 0; i < std::size(kVals); ++i) {
764 EXPECT_EQ(CPDF_Object::kString, string_array->GetObjectAt(i)->GetType());
765 EXPECT_STREQ(kVals[i], string_array->GetObjectAt(i)->GetString().c_str());
766 EXPECT_EQ(CPDF_Object::kName, name_array->GetObjectAt(i)->GetType());
767 EXPECT_STREQ(kVals[i], name_array->GetObjectAt(i)->GetString().c_str());
768 }
769}
770
772 auto holder = std::make_unique<CPDF_IndirectObjectHolder>();
773 auto boolean_obj = pdfium::MakeRetain<CPDF_Boolean>(true);
774 auto int_obj = pdfium::MakeRetain<CPDF_Number>(-1234);
775 auto float_obj = pdfium::MakeRetain<CPDF_Number>(2345.089f);
776 auto str_obj =
777 pdfium::MakeRetain<CPDF_String>(nullptr, "Adsfdsf 343434 %&&*\n", false);
778 auto name_obj = pdfium::MakeRetain<CPDF_Name>(nullptr, "Title:");
779 auto null_obj = pdfium::MakeRetain<CPDF_Null>();
780 RetainPtr<CPDF_Object> indirect_objs[] = {boolean_obj, int_obj, float_obj,
781 str_obj, name_obj, null_obj};
782 unsigned int obj_nums[] = {2, 4, 7, 2345, 799887, 1};
783 auto arr = pdfium::MakeRetain<CPDF_Array>();
784 auto arr1 = pdfium::MakeRetain<CPDF_Array>();
785 // Create two arrays of references by different AddReference() APIs.
786 for (size_t i = 0; i < std::size(indirect_objs); ++i) {
787 holder->ReplaceIndirectObjectIfHigherGeneration(obj_nums[i],
788 indirect_objs[i]);
789 arr->AppendNew<CPDF_Reference>(holder.get(), obj_nums[i]);
790 arr1->AppendNew<CPDF_Reference>(holder.get(),
791 indirect_objs[i]->GetObjNum());
792 }
793 // Check indirect objects.
794 for (size_t i = 0; i < std::size(obj_nums); ++i)
795 EXPECT_EQ(indirect_objs[i], holder->GetOrParseIndirectObject(obj_nums[i]));
796 // Check arrays.
797 EXPECT_EQ(arr->size(), arr1->size());
798 for (size_t i = 0; i < arr->size(); ++i) {
799 EXPECT_EQ(CPDF_Object::kReference, arr->GetObjectAt(i)->GetType());
800 EXPECT_EQ(indirect_objs[i], arr->GetObjectAt(i)->GetDirect());
801 EXPECT_EQ(indirect_objs[i], arr->GetDirectObjectAt(i));
802 EXPECT_EQ(CPDF_Object::kReference, arr1->GetObjectAt(i)->GetType());
803 EXPECT_EQ(indirect_objs[i], arr1->GetObjectAt(i)->GetDirect());
804 EXPECT_EQ(indirect_objs[i], arr1->GetDirectObjectAt(i));
805 }
806}
807
809 CPDF_IndirectObjectHolder objects_holder;
810 auto array = pdfium::MakeRetain<CPDF_Array>();
811 array->AppendNew<CPDF_Reference>(&objects_holder, 1234);
812 ASSERT_EQ(1U, array->size());
813 RetainPtr<const CPDF_Object> obj = array->GetObjectAt(0);
814 ASSERT_TRUE(obj);
815 EXPECT_TRUE(obj->IsReference());
816
817 RetainPtr<CPDF_Object> cloned_array_object = array->CloneDirectObject();
818 ASSERT_TRUE(cloned_array_object);
819 ASSERT_TRUE(cloned_array_object->IsArray());
820
821 RetainPtr<CPDF_Array> cloned_array = ToArray(std::move(cloned_array_object));
822 ASSERT_EQ(0U, cloned_array->size());
823 RetainPtr<const CPDF_Object> cloned_obj = cloned_array->GetObjectAt(0);
824 EXPECT_FALSE(cloned_obj);
825}
826
828 CPDF_IndirectObjectHolder objects_holder;
829 auto array = pdfium::MakeRetain<CPDF_Array>();
830 auto pObj = array->AppendNew<CPDF_Number>(42);
831 array->ConvertToIndirectObjectAt(0, &objects_holder);
832 RetainPtr<const CPDF_Object> pRef = array->GetObjectAt(0);
833 RetainPtr<const CPDF_Object> pNum = array->GetDirectObjectAt(0);
834 EXPECT_TRUE(pRef->IsReference());
835 EXPECT_TRUE(pNum->IsNumber());
836 EXPECT_NE(pObj, pRef);
837 EXPECT_EQ(pObj, pNum);
838 EXPECT_EQ(42, array->GetIntegerAt(0));
839}
840
842 DataVector<uint8_t> data(100);
843 auto stream = pdfium::MakeRetain<CPDF_Stream>(
844 data, pdfium::MakeRetain<CPDF_Dictionary>());
845 EXPECT_EQ(static_cast<int>(data.size()),
846 stream->GetDict()->GetIntegerFor(pdfium::stream::kLength));
847
848 stream->GetMutableDict()->SetNewFor<CPDF_String>(pdfium::stream::kFilter,
849 L"SomeFilter");
850 stream->GetMutableDict()->SetNewFor<CPDF_String>(pdfium::stream::kDecodeParms,
851 L"SomeParams");
852
853 DataVector<uint8_t> new_data(data.size() * 2);
854 stream->SetData(new_data);
855
856 // The "Length" field should be updated for new data size.
857 EXPECT_EQ(static_cast<int>(new_data.size()),
858 stream->GetDict()->GetIntegerFor(pdfium::stream::kLength));
859
860 // The "Filter" and "DecodeParms" fields should not be changed.
861 EXPECT_EQ(stream->GetDict()->GetUnicodeTextFor(pdfium::stream::kFilter),
862 L"SomeFilter");
863 EXPECT_EQ(stream->GetDict()->GetUnicodeTextFor(pdfium::stream::kDecodeParms),
864 L"SomeParams");
865}
866
868 DataVector<uint8_t> data(100);
869 auto stream = pdfium::MakeRetain<CPDF_Stream>(
870 data, pdfium::MakeRetain<CPDF_Dictionary>());
871 EXPECT_EQ(static_cast<int>(data.size()),
872 stream->GetDict()->GetIntegerFor(pdfium::stream::kLength));
873
874 stream->GetMutableDict()->SetNewFor<CPDF_String>(pdfium::stream::kFilter,
875 L"SomeFilter");
876 stream->GetMutableDict()->SetNewFor<CPDF_String>(pdfium::stream::kDecodeParms,
877 L"SomeParams");
878
879 DataVector<uint8_t> new_data(data.size() * 2);
880 stream->SetDataAndRemoveFilter(new_data);
881 // The "Length" field should be updated for new data size.
882 EXPECT_EQ(static_cast<int>(new_data.size()),
883 stream->GetDict()->GetIntegerFor(pdfium::stream::kLength));
884
885 // The "Filter" and "DecodeParms" should be removed.
886 EXPECT_FALSE(stream->GetDict()->KeyExist(pdfium::stream::kFilter));
887 EXPECT_FALSE(stream->GetDict()->KeyExist(pdfium::stream::kDecodeParms));
888}
889
891 static constexpr uint32_t kBufSize = 100;
892 // The length field should be created on stream create.
893 {
894 auto stream = pdfium::MakeRetain<CPDF_Stream>(
895 DataVector<uint8_t>(kBufSize), pdfium::MakeRetain<CPDF_Dictionary>());
896 EXPECT_EQ(static_cast<int>(kBufSize),
897 stream->GetDict()->GetIntegerFor(pdfium::stream::kLength));
898 }
899 // The length field should be corrected on stream create.
900 {
901 auto dict = pdfium::MakeRetain<CPDF_Dictionary>();
902 dict->SetNewFor<CPDF_Number>(pdfium::stream::kLength, 30000);
903 auto stream = pdfium::MakeRetain<CPDF_Stream>(DataVector<uint8_t>(kBufSize),
904 std::move(dict));
905 EXPECT_EQ(static_cast<int>(kBufSize),
906 stream->GetDict()->GetIntegerFor(pdfium::stream::kLength));
907 }
908}
909
911 CPDF_IndirectObjectHolder objects_holder;
912 auto dict = pdfium::MakeRetain<CPDF_Dictionary>();
913 dict->SetNewFor<CPDF_Reference>("foo", &objects_holder, 1234);
914 ASSERT_EQ(1U, dict->size());
915 RetainPtr<const CPDF_Object> obj = dict->GetObjectFor("foo");
916 ASSERT_TRUE(obj);
917 EXPECT_TRUE(obj->IsReference());
918
919 RetainPtr<CPDF_Object> cloned_dict_object = dict->CloneDirectObject();
920 ASSERT_TRUE(cloned_dict_object);
921 ASSERT_TRUE(cloned_dict_object->IsDictionary());
922
923 RetainPtr<CPDF_Dictionary> cloned_dict =
924 ToDictionary(std::move(cloned_dict_object));
925 ASSERT_EQ(0U, cloned_dict->size());
926 RetainPtr<const CPDF_Object> cloned_obj = cloned_dict->GetObjectFor("foo");
927 EXPECT_FALSE(cloned_obj);
928}
929
931 {
932 // Create a dictionary/array pair with a reference loop.
933 auto arr_obj = pdfium::MakeRetain<CPDF_Array>();
934 auto dict_obj = arr_obj->InsertNewAt<CPDF_Dictionary>(0);
935 dict_obj->SetFor("arr", arr_obj);
936 // Clone this object to see whether stack overflow will be triggered.
937 RetainPtr<CPDF_Array> cloned_array = ToArray(arr_obj->Clone());
938 // Cloned object should be the same as the original.
939 ASSERT_TRUE(cloned_array);
940 EXPECT_EQ(1u, cloned_array->size());
941 RetainPtr<const CPDF_Object> cloned_dict = cloned_array->GetObjectAt(0);
942 ASSERT_TRUE(cloned_dict);
943 ASSERT_TRUE(cloned_dict->IsDictionary());
944 // Recursively referenced object is not cloned.
945 EXPECT_FALSE(cloned_dict->AsDictionary()->GetObjectFor("arr"));
946 dict_obj->RemoveFor("arr"); // Break deliberate cycle for cleanup.
947 }
948 {
949 CPDF_IndirectObjectHolder objects_holder;
950 // Create an object with a reference loop.
951 auto dict_obj = objects_holder.NewIndirect<CPDF_Dictionary>();
952 auto arr_obj = pdfium::MakeRetain<CPDF_Array>();
953 arr_obj->InsertNewAt<CPDF_Reference>(0, &objects_holder,
954 dict_obj->GetObjNum());
955 RetainPtr<const CPDF_Object> elem0 = arr_obj->GetObjectAt(0);
956 dict_obj->SetFor("arr", std::move(arr_obj));
957 EXPECT_EQ(1u, dict_obj->GetObjNum());
958 ASSERT_TRUE(elem0);
959 ASSERT_TRUE(elem0->IsReference());
960 EXPECT_EQ(1u, elem0->AsReference()->GetRefObjNum());
961 EXPECT_EQ(dict_obj, elem0->AsReference()->GetDirect());
962
963 // Clone this object to see whether stack overflow will be triggered.
964 RetainPtr<CPDF_Dictionary> cloned_dict =
965 ToDictionary(dict_obj->CloneDirectObject());
966 // Cloned object should be the same as the original.
967 ASSERT_TRUE(cloned_dict);
968 RetainPtr<const CPDF_Object> cloned_arr = cloned_dict->GetObjectFor("arr");
969 ASSERT_TRUE(cloned_arr);
970 ASSERT_TRUE(cloned_arr->IsArray());
971 EXPECT_EQ(0U, cloned_arr->AsArray()->size());
972 // Recursively referenced object is not cloned.
973 EXPECT_FALSE(cloned_arr->AsArray()->GetObjectAt(0));
974 dict_obj->RemoveFor("arr"); // Break deliberate cycle for cleanup.
975 }
976}
977
979 CPDF_IndirectObjectHolder objects_holder;
980 auto dict = pdfium::MakeRetain<CPDF_Dictionary>();
981 auto pObj = dict->SetNewFor<CPDF_Number>("clams", 42);
982 dict->ConvertToIndirectObjectFor("clams", &objects_holder);
983 RetainPtr<const CPDF_Object> pRef = dict->GetObjectFor("clams");
984 RetainPtr<const CPDF_Object> pNum = dict->GetDirectObjectFor("clams");
985 EXPECT_TRUE(pRef->IsReference());
986 EXPECT_TRUE(pNum->IsNumber());
987 EXPECT_NE(pObj, pRef);
988 EXPECT_EQ(pObj, pNum);
989 EXPECT_EQ(42, dict->GetIntegerFor("clams"));
990}
991
993 auto dict = pdfium::MakeRetain<CPDF_Dictionary>();
994 auto pObj = dict->SetNewFor<CPDF_Number>("child", 42);
995 auto extracted_object = dict->RemoveFor("child");
996 EXPECT_EQ(pObj, extracted_object.Get());
997
998 extracted_object = dict->RemoveFor("non_exists_object");
999 EXPECT_FALSE(extracted_object);
1000}
1001
1003 auto obj_holder = std::make_unique<CPDF_IndirectObjectHolder>();
1004 auto original_ref = pdfium::MakeRetain<CPDF_Reference>(obj_holder.get(), 42);
1005 original_ref->SetObjNum(1952);
1006 ASSERT_FALSE(original_ref->IsInline());
1007
1008 auto ref_obj = original_ref->MakeReference(obj_holder.get());
1009
1010 ASSERT_TRUE(ref_obj->IsReference());
1011 // We do not allow reference to reference.
1012 // New reference should have same RefObjNum.
1013 EXPECT_EQ(original_ref->GetRefObjNum(),
1014 ToReference(ref_obj.Get())->GetRefObjNum());
1015}
CPDF_DictionaryLocker(const CPDF_Dictionary *pDictionary)
bool IsInteger() const
Definition cpdf_number.h:30
virtual Type GetType() const =0
virtual ByteString GetString() const
const CPDF_Array * AsArray() const
virtual int GetInteger() const
const CPDF_Dictionary * AsDictionary() const
const CPDF_Reference * AsReference() const
const CPDF_Number * AsNumber() const
uint32_t GetRefObjNum() const
RetainPtr< CPDF_Array > m_ArrayObj
RetainPtr< CPDF_Dictionary > m_DictObj
std::vector< RetainPtr< CPDF_Object > > m_RefObjs
std::unique_ptr< CPDF_IndirectObjectHolder > m_ObjHolder
bool Equal(const CPDF_Object *obj1, const CPDF_Object *obj2)
std::vector< uint32_t > m_IndirectObjNums
std::vector< int > m_DirectObjTypes
std::vector< RetainPtr< CPDF_Object > > m_DirectObjs
void SetUp() override
RetainPtr< CPDF_Dictionary > m_StreamDictObj
bool operator==(const ByteString &other) const
TEST_F(PDFObjectsTest, GetString)
TEST(FXCRYPT, MD5GenerateEmtpyData)
const char kDecodeParms[]