35 auto dict = pdfium::MakeRetain<CPDF_Dictionary>();
36 dict->SetNewFor<CPDF_Name>(
"Type",
"ObjStm");
37 dict->SetNewFor<CPDF_Number>(
"N", 3);
38 dict->SetNewFor<CPDF_Number>(
"First", kNormalStreamContentOffset);
40 ByteStringView contents_view(kNormalStreamContent);
41 auto stream = pdfium::MakeRetain<CPDF_Stream>(
42 DataVector<uint8_t>(contents_view.begin(), contents_view.end()), dict);
43 auto obj_stream = CPDF_ObjectStream::Create(
std::move(stream));
44 ASSERT_TRUE(obj_stream);
46 EXPECT_THAT(obj_stream->object_info(),
55 EXPECT_EQ(10u, obj10->GetObjNum());
56 EXPECT_EQ(0u, obj10->GetGenNum());
57 EXPECT_TRUE(obj10->IsDictionary());
61 EXPECT_EQ(11u, obj11->GetObjNum());
62 EXPECT_EQ(0u, obj11->GetGenNum());
63 EXPECT_TRUE(obj11->IsArray());
67 EXPECT_EQ(12u, obj12->GetObjNum());
68 EXPECT_EQ(0u, obj12->GetGenNum());
69 EXPECT_TRUE(obj12->IsNumber());
72 EXPECT_FALSE(obj_stream->ParseObject(&holder, 10, 1));
73 EXPECT_FALSE(obj_stream->ParseObject(&holder, 10, 2));
74 EXPECT_FALSE(obj_stream->ParseObject(&holder, 10, 3));
75 EXPECT_FALSE(obj_stream->ParseObject(&holder, 11, 0));
76 EXPECT_FALSE(obj_stream->ParseObject(&holder, 11, 2));
77 EXPECT_FALSE(obj_stream->ParseObject(&holder, 11, 3));
78 EXPECT_FALSE(obj_stream->ParseObject(&holder, 12, 0));
79 EXPECT_FALSE(obj_stream->ParseObject(&holder, 12, 1));
80 EXPECT_FALSE(obj_stream->ParseObject(&holder, 12, 3));
92 auto dict = pdfium::MakeRetain<CPDF_Dictionary>();
93 dict->SetNewFor<CPDF_Number>(
"N", 3);
94 dict->SetNewFor<CPDF_Number>(
"First", 5);
96 ByteStringView contents_view(kNormalStreamContent);
97 auto stream = pdfium::MakeRetain<CPDF_Stream>(
98 DataVector<uint8_t>(contents_view.begin(), contents_view.end()), dict);
99 EXPECT_FALSE(CPDF_ObjectStream::Create(
std::move(stream)));
103 auto dict = pdfium::MakeRetain<CPDF_Dictionary>();
104 dict->SetNewFor<CPDF_String>(
"Type",
"ObjStm",
false);
105 dict->SetNewFor<CPDF_Number>(
"N", 3);
106 dict->SetNewFor<CPDF_Number>(
"First", 5);
108 ByteStringView contents_view(kNormalStreamContent);
109 auto stream = pdfium::MakeRetain<CPDF_Stream>(
110 DataVector<uint8_t>(contents_view.begin(), contents_view.end()), dict);
111 EXPECT_FALSE(CPDF_ObjectStream::Create(
std::move(stream)));
115 auto dict = pdfium::MakeRetain<CPDF_Dictionary>();
116 dict->SetNewFor<CPDF_Name>(
"Type",
"ObjStmmmm");
117 dict->SetNewFor<CPDF_Number>(
"N", 3);
118 dict->SetNewFor<CPDF_Number>(
"First", 5);
120 ByteStringView contents_view(kNormalStreamContent);
121 auto stream = pdfium::MakeRetain<CPDF_Stream>(
122 DataVector<uint8_t>(contents_view.begin(), contents_view.end()), dict);
123 EXPECT_FALSE(CPDF_ObjectStream::Create(
std::move(stream)));
127 auto dict = pdfium::MakeRetain<CPDF_Dictionary>();
128 dict->SetNewFor<CPDF_Name>(
"Type",
"ObjStm");
129 dict->SetNewFor<CPDF_Number>(
"First", 5);
131 ByteStringView contents_view(kNormalStreamContent);
132 auto stream = pdfium::MakeRetain<CPDF_Stream>(
133 DataVector<uint8_t>(contents_view.begin(), contents_view.end()), dict);
134 EXPECT_FALSE(CPDF_ObjectStream::Create(
std::move(stream)));
138 auto dict = pdfium::MakeRetain<CPDF_Dictionary>();
139 dict->SetNewFor<CPDF_Name>(
"Type",
"ObjStm");
140 dict->SetNewFor<CPDF_Number>(
"N", 2.2f);
141 dict->SetNewFor<CPDF_Number>(
"First", 5);
143 ByteStringView contents_view(kNormalStreamContent);
144 auto stream = pdfium::MakeRetain<CPDF_Stream>(
145 DataVector<uint8_t>(contents_view.begin(), contents_view.end()), dict);
146 EXPECT_FALSE(CPDF_ObjectStream::Create(
std::move(stream)));
150 auto dict = pdfium::MakeRetain<CPDF_Dictionary>();
151 dict->SetNewFor<CPDF_Name>(
"Type",
"ObjStm");
152 dict->SetNewFor<CPDF_Number>(
"N", -1);
153 dict->SetNewFor<CPDF_Number>(
"First", 5);
155 ByteStringView contents_view(kNormalStreamContent);
156 auto stream = pdfium::MakeRetain<CPDF_Stream>(
157 DataVector<uint8_t>(contents_view.begin(), contents_view.end()), dict);
158 EXPECT_FALSE(CPDF_ObjectStream::Create(
std::move(stream)));
162 auto dict = pdfium::MakeRetain<CPDF_Dictionary>();
163 dict->SetNewFor<CPDF_Name>(
"Type",
"ObjStm");
164 dict->SetNewFor<CPDF_Number>(
"N", 999999999);
165 dict->SetNewFor<CPDF_Number>(
"First", 5);
167 ByteStringView contents_view(kNormalStreamContent);
168 auto stream = pdfium::MakeRetain<CPDF_Stream>(
169 DataVector<uint8_t>(contents_view.begin(), contents_view.end()), dict);
170 EXPECT_FALSE(CPDF_ObjectStream::Create(
std::move(stream)));
174 auto dict = pdfium::MakeRetain<CPDF_Dictionary>();
175 dict->SetNewFor<CPDF_Name>(
"Type",
"ObjStm");
176 dict->SetNewFor<CPDF_Number>(
"N", 3);
178 ByteStringView contents_view(kNormalStreamContent);
179 auto stream = pdfium::MakeRetain<CPDF_Stream>(
180 DataVector<uint8_t>(contents_view.begin(), contents_view.end()), dict);
181 EXPECT_FALSE(CPDF_ObjectStream::Create(
std::move(stream)));
185 auto dict = pdfium::MakeRetain<CPDF_Dictionary>();
186 dict->SetNewFor<CPDF_Name>(
"Type",
"ObjStm");
187 dict->SetNewFor<CPDF_Number>(
"N", 3);
188 dict->SetNewFor<CPDF_Number>(
"First", 5.5f);
190 ByteStringView contents_view(kNormalStreamContent);
191 auto stream = pdfium::MakeRetain<CPDF_Stream>(
192 DataVector<uint8_t>(contents_view.begin(), contents_view.end()), dict);
193 EXPECT_FALSE(CPDF_ObjectStream::Create(
std::move(stream)));
197 auto dict = pdfium::MakeRetain<CPDF_Dictionary>();
198 dict->SetNewFor<CPDF_Name>(
"Type",
"ObjStm");
199 dict->SetNewFor<CPDF_Number>(
"N", 3);
200 dict->SetNewFor<CPDF_Number>(
"First", -5);
202 ByteStringView contents_view(kNormalStreamContent);
203 auto stream = pdfium::MakeRetain<CPDF_Stream>(
204 DataVector<uint8_t>(contents_view.begin(), contents_view.end()), dict);
205 EXPECT_FALSE(CPDF_ObjectStream::Create(
std::move(stream)));
209 auto dict = pdfium::MakeRetain<CPDF_Dictionary>();
210 dict->SetNewFor<CPDF_Name>(
"Type",
"ObjStm");
211 dict->SetNewFor<CPDF_Number>(
"N", 3);
212 constexpr int kTooBigOffset =
std::size(kNormalStreamContent);
213 dict->SetNewFor<CPDF_Number>(
"First", kTooBigOffset);
215 ByteStringView contents_view(kNormalStreamContent);
216 auto stream = pdfium::MakeRetain<CPDF_Stream>(
217 DataVector<uint8_t>(contents_view.begin(), contents_view.end()), dict);
218 auto obj_stream = CPDF_ObjectStream::Create(
std::move(stream));
219 ASSERT_TRUE(obj_stream);
221 EXPECT_THAT(obj_stream->object_info(),
227 EXPECT_FALSE(obj_stream->ParseObject(&holder, 10, 0));
228 EXPECT_FALSE(obj_stream->ParseObject(&holder, 11, 1));
229 EXPECT_FALSE(obj_stream->ParseObject(&holder, 12, 2));
233 auto dict = pdfium::MakeRetain<CPDF_Dictionary>();
234 dict->SetNewFor<CPDF_Name>(
"Type",
"ObjStm");
235 dict->SetNewFor<CPDF_Number>(
"N", 2);
236 dict->SetNewFor<CPDF_Number>(
"First", kNormalStreamContentOffset);
238 ByteStringView contents_view(kNormalStreamContent);
239 auto stream = pdfium::MakeRetain<CPDF_Stream>(
240 DataVector<uint8_t>(contents_view.begin(), contents_view.end()), dict);
241 auto obj_stream = CPDF_ObjectStream::Create(
std::move(stream));
242 ASSERT_TRUE(obj_stream);
244 EXPECT_THAT(obj_stream->object_info(),
251 EXPECT_EQ(10u, obj10->GetObjNum());
252 EXPECT_EQ(0u, obj10->GetGenNum());
253 EXPECT_TRUE(obj10->IsDictionary());
257 EXPECT_EQ(11u, obj11->GetObjNum());
258 EXPECT_EQ(0u, obj11->GetGenNum());
259 EXPECT_TRUE(obj11->IsArray());
261 EXPECT_FALSE(obj_stream->ParseObject(&holder, 12, 2));
265 auto dict = pdfium::MakeRetain<CPDF_Dictionary>();
266 dict->SetNewFor<CPDF_Name>(
"Type",
"ObjStm");
267 dict->SetNewFor<CPDF_Number>(
"N", 9);
268 dict->SetNewFor<CPDF_Number>(
"First", kNormalStreamContentOffset);
270 ByteStringView contents_view(kNormalStreamContent);
271 auto stream = pdfium::MakeRetain<CPDF_Stream>(
272 DataVector<uint8_t>(contents_view.begin(), contents_view.end()), dict);
273 auto obj_stream = CPDF_ObjectStream::Create(
std::move(stream));
274 ASSERT_TRUE(obj_stream);
277 EXPECT_THAT(obj_stream->object_info(),
284 EXPECT_FALSE(obj_stream->ParseObject(&holder, 2, 0));
285 EXPECT_FALSE(obj_stream->ParseObject(&holder, 2, 1));
286 EXPECT_FALSE(obj_stream->ParseObject(&holder, 2, 2));
287 EXPECT_FALSE(obj_stream->ParseObject(&holder, 2, 3));
288 EXPECT_FALSE(obj_stream->ParseObject(&holder, 2, 4));
292 auto dict = pdfium::MakeRetain<CPDF_Dictionary>();
293 dict->SetNewFor<CPDF_Name>(
"Type",
"ObjStm");
294 dict->SetNewFor<CPDF_Number>(
"N", 3);
295 dict->SetNewFor<CPDF_Number>(
"First", 19);
297 const char kStreamContent[] =
"10 0 hi 14 12 21<</Name /Foo>>[1 2 3]4";
298 ByteStringView contents_view(kStreamContent);
299 auto stream = pdfium::MakeRetain<CPDF_Stream>(
300 DataVector<uint8_t>(contents_view.begin(), contents_view.end()), dict);
301 auto obj_stream = CPDF_ObjectStream::Create(
std::move(stream));
302 ASSERT_TRUE(obj_stream);
304 EXPECT_THAT(obj_stream->object_info(),
310 auto dict = pdfium::MakeRetain<CPDF_Dictionary>();
311 dict->SetNewFor<CPDF_Name>(
"Type",
"ObjStm");
312 dict->SetNewFor<CPDF_Number>(
"N", 3);
313 dict->SetNewFor<CPDF_Number>(
"First", 16);
315 const char kStreamContent[] =
"10 0 11 hi 12 21<</Name /Foo>>[1 2 3]4";
316 ByteStringView contents_view(kStreamContent);
317 auto stream = pdfium::MakeRetain<CPDF_Stream>(
318 DataVector<uint8_t>(contents_view.begin(), contents_view.end()), dict);
319 auto obj_stream = CPDF_ObjectStream::Create(
std::move(stream));
320 ASSERT_TRUE(obj_stream);
323 EXPECT_THAT(obj_stream->object_info(),
331 EXPECT_EQ(10u, obj10->GetObjNum());
332 EXPECT_EQ(0u, obj10->GetGenNum());
333 EXPECT_TRUE(obj10->IsDictionary());
337 EXPECT_EQ(11u, obj11->GetObjNum());
338 EXPECT_EQ(0u, obj11->GetGenNum());
339 EXPECT_TRUE(obj11->IsDictionary());
343 auto dict = pdfium::MakeRetain<CPDF_Dictionary>();
344 dict->SetNewFor<CPDF_Name>(
"Type",
"ObjStm");
345 dict->SetNewFor<CPDF_Number>(
"N", 3);
346 dict->SetNewFor<CPDF_Number>(
"First", 16);
348 const char kStreamContent[] =
"10 0 11 -1 12 21<</Name /Foo>>[1 2 3]4";
349 ByteStringView contents_view(kStreamContent);
350 auto stream = pdfium::MakeRetain<CPDF_Stream>(
351 DataVector<uint8_t>(contents_view.begin(), contents_view.end()), dict);
352 auto obj_stream = CPDF_ObjectStream::Create(
std::move(stream));
353 ASSERT_TRUE(obj_stream);
356 EXPECT_THAT(obj_stream->object_info(),
362 EXPECT_FALSE(obj_stream->ParseObject(&holder, 11, 1));
366 auto dict = pdfium::MakeRetain<CPDF_Dictionary>();
367 dict->SetNewFor<CPDF_Name>(
"Type",
"ObjStm");
368 dict->SetNewFor<CPDF_Number>(
"N", 3);
369 dict->SetNewFor<CPDF_Number>(
"First", 17);
371 const char kStreamContent[] =
"10 0 11 999 12 21<</Name /Foo>>[1 2 3]4";
372 ByteStringView contents_view(kStreamContent);
373 auto stream = pdfium::MakeRetain<CPDF_Stream>(
374 DataVector<uint8_t>(contents_view.begin(), contents_view.end()), dict);
375 auto obj_stream = CPDF_ObjectStream::Create(
std::move(stream));
376 ASSERT_TRUE(obj_stream);
379 EXPECT_THAT(obj_stream->object_info(),
385 EXPECT_FALSE(obj_stream->ParseObject(&holder, 11, 1));
389 auto dict = pdfium::MakeRetain<CPDF_Dictionary>();
390 dict->SetNewFor<CPDF_Name>(
"Type",
"ObjStm");
391 dict->SetNewFor<CPDF_Number>(
"N", 3);
392 dict->SetNewFor<CPDF_Number>(
"First", 16);
394 const char kStreamContent[] =
"10 0 10 14 12 21<</Name /Foo>>[1 2 3]4";
395 ByteStringView contents_view(kStreamContent);
396 auto stream = pdfium::MakeRetain<CPDF_Stream>(
397 DataVector<uint8_t>(contents_view.begin(), contents_view.end()), dict);
398 auto obj_stream = CPDF_ObjectStream::Create(
std::move(stream));
399 ASSERT_TRUE(obj_stream);
401 EXPECT_THAT(obj_stream->object_info(),
409 EXPECT_EQ(10u, obj10->GetObjNum());
410 EXPECT_EQ(0u, obj10->GetGenNum());
411 EXPECT_TRUE(obj10->IsDictionary());
413 obj10 = obj_stream->ParseObject(&holder, 10, 1);
415 EXPECT_EQ(10u, obj10->GetObjNum());
416 EXPECT_EQ(0u, obj10->GetGenNum());
417 EXPECT_TRUE(obj10->IsArray());
419 EXPECT_FALSE(obj_stream->ParseObject(&holder, 10, 2));
420 EXPECT_FALSE(obj_stream->ParseObject(&holder, 10, 3));
424 EXPECT_EQ(12u, obj12->GetObjNum());
425 EXPECT_EQ(0u, obj12->GetGenNum());
426 EXPECT_TRUE(obj12->IsNumber());
432 auto dict = pdfium::MakeRetain<CPDF_Dictionary>();
433 dict->SetNewFor<CPDF_Name>(
"Type",
"ObjStm");
434 dict->SetNewFor<CPDF_Number>(
"N", 3);
435 dict->SetNewFor<CPDF_Number>(
"First", 16);
437 const char kStreamContent[] =
"11 0 12 14 10 21<</Name /Foo>>[1 2 3]4";
438 ByteStringView contents_view(kStreamContent);
439 auto stream = pdfium::MakeRetain<CPDF_Stream>(
440 DataVector<uint8_t>(contents_view.begin(), contents_view.end()), dict);
441 auto obj_stream = CPDF_ObjectStream::Create(
std::move(stream));
442 ASSERT_TRUE(obj_stream);
444 EXPECT_THAT(obj_stream->object_info(),
452 EXPECT_EQ(10u, obj10->GetObjNum());
453 EXPECT_EQ(0u, obj10->GetGenNum());
454 EXPECT_TRUE(obj10->IsNumber());
458 EXPECT_EQ(11u, obj11->GetObjNum());
459 EXPECT_EQ(0u, obj11->GetGenNum());
460 EXPECT_TRUE(obj11->IsDictionary());
464 EXPECT_EQ(12u, obj12->GetObjNum());
465 EXPECT_EQ(0u, obj12->GetGenNum());
466 EXPECT_TRUE(obj12->IsArray());
474 auto dict = pdfium::MakeRetain<CPDF_Dictionary>();
475 dict->SetNewFor<CPDF_Name>(
"Type",
"ObjStm");
476 dict->SetNewFor<CPDF_Number>(
"N", 3);
477 dict->SetNewFor<CPDF_Number>(
"First", 16);
479 const char kStreamContent[] =
"10 21 11 0 12 14<</Name /Foo>>[1 2 3]4";
480 ByteStringView contents_view(kStreamContent);
481 auto stream = pdfium::MakeRetain<CPDF_Stream>(
482 DataVector<uint8_t>(contents_view.begin(), contents_view.end()), dict);
483 auto obj_stream = CPDF_ObjectStream::Create(
std::move(stream));
484 ASSERT_TRUE(obj_stream);
486 EXPECT_THAT(obj_stream->object_info(),
494 EXPECT_EQ(10u, obj10->GetObjNum());
495 EXPECT_EQ(0u, obj10->GetGenNum());
496 EXPECT_TRUE(obj10->IsNumber());
500 EXPECT_EQ(11u, obj11->GetObjNum());
501 EXPECT_EQ(0u, obj11->GetGenNum());
502 EXPECT_TRUE(obj11->IsDictionary());
506 EXPECT_EQ(12u, obj12->GetObjNum());
507 EXPECT_EQ(0u, obj12->GetGenNum());
508 EXPECT_TRUE(obj12->IsArray());