Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2049)

Side by Side Diff: core/src/fpdfapi/fpdf_parser/fpdf_parser_parser_unittest.cpp

Issue 1650793002: Remove the m_V5Type member variable from CPDF_Parser. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: rebase Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 PDFium Authors. All rights reserved. 1 // Copyright 2015 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/include/fpdfapi/fpdf_parser.h" 5 #include "core/include/fpdfapi/fpdf_parser.h"
6 #include "core/include/fxcrt/fx_stream.h" 6 #include "core/include/fxcrt/fx_stream.h"
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 #include "testing/utils/path_service.h" 8 #include "testing/utils/path_service.h"
9 9
10 // Functions to help test an array's content against expected results. 10 // Functions to help test an array's content against expected results.
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 "0000000331 00000 n \n" 283 "0000000331 00000 n \n"
284 "0000000409 00000 n \n" 284 "0000000409 00000 n \n"
285 "trail"; // Needed to end cross ref table reading. 285 "trail"; // Needed to end cross ref table reading.
286 CPDF_TestParser parser; 286 CPDF_TestParser parser;
287 ASSERT_TRUE( 287 ASSERT_TRUE(
288 parser.InitTestFromBuffer(xref_table, FX_ArraySize(xref_table))); 288 parser.InitTestFromBuffer(xref_table, FX_ArraySize(xref_table)));
289 289
290 ASSERT_TRUE(parser.LoadCrossRefV4(0, 0, FALSE)); 290 ASSERT_TRUE(parser.LoadCrossRefV4(0, 0, FALSE));
291 const FX_FILESIZE offsets[] = {0, 17, 81, 0, 331, 409}; 291 const FX_FILESIZE offsets[] = {0, 17, 81, 0, 331, 409};
292 const uint8_t types[] = {0, 1, 1, 0, 1, 1}; 292 const uint8_t types[] = {0, 1, 1, 0, 1, 1};
293 for (size_t i = 0; i < FX_ArraySize(offsets); ++i) 293 for (size_t i = 0; i < FX_ArraySize(offsets); ++i) {
294 EXPECT_EQ(offsets[i], parser.m_ObjectInfo[i].pos); 294 EXPECT_EQ(offsets[i], parser.m_ObjectInfo[i].pos);
295 ASSERT_TRUE(CompareArray(parser.m_V5Type, types, FX_ArraySize(types))); 295 EXPECT_EQ(types[i], parser.m_ObjectInfo[i].type);
296 }
296 } 297 }
297 { 298 {
298 const unsigned char xref_table[] = 299 const unsigned char xref_table[] =
299 "xref \n" 300 "xref \n"
300 "0 1 \n" 301 "0 1 \n"
301 "0000000000 65535 f \n" 302 "0000000000 65535 f \n"
302 "3 1 \n" 303 "3 1 \n"
303 "0000025325 00000 n \n" 304 "0000025325 00000 n \n"
304 "8 2 \n" 305 "8 2 \n"
305 "0000025518 00002 n \n" 306 "0000025518 00002 n \n"
306 "0000025635 00000 n \n" 307 "0000025635 00000 n \n"
307 "12 1 \n" 308 "12 1 \n"
308 "0000025777 00000 n \n" 309 "0000025777 00000 n \n"
309 "trail"; // Needed to end cross ref table reading. 310 "trail"; // Needed to end cross ref table reading.
310 CPDF_TestParser parser; 311 CPDF_TestParser parser;
311 ASSERT_TRUE( 312 ASSERT_TRUE(
312 parser.InitTestFromBuffer(xref_table, FX_ArraySize(xref_table))); 313 parser.InitTestFromBuffer(xref_table, FX_ArraySize(xref_table)));
313 314
314 ASSERT_TRUE(parser.LoadCrossRefV4(0, 0, FALSE)); 315 ASSERT_TRUE(parser.LoadCrossRefV4(0, 0, FALSE));
315 const FX_FILESIZE offsets[] = {0, 0, 0, 25325, 0, 0, 0, 316 const FX_FILESIZE offsets[] = {0, 0, 0, 25325, 0, 0, 0,
316 0, 25518, 25635, 0, 0, 25777}; 317 0, 25518, 25635, 0, 0, 25777};
317 const uint8_t types[] = {0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1}; 318 const uint8_t types[] = {0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1};
318 for (size_t i = 0; i < FX_ArraySize(offsets); ++i) 319 for (size_t i = 0; i < FX_ArraySize(offsets); ++i) {
319 EXPECT_EQ(offsets[i], parser.m_ObjectInfo[i].pos); 320 EXPECT_EQ(offsets[i], parser.m_ObjectInfo[i].pos);
320 ASSERT_TRUE(CompareArray(parser.m_V5Type, types, FX_ArraySize(types))); 321 EXPECT_EQ(types[i], parser.m_ObjectInfo[i].type);
322 }
321 } 323 }
322 { 324 {
323 const unsigned char xref_table[] = 325 const unsigned char xref_table[] =
324 "xref \n" 326 "xref \n"
325 "0 1 \n" 327 "0 1 \n"
326 "0000000000 65535 f \n" 328 "0000000000 65535 f \n"
327 "3 1 \n" 329 "3 1 \n"
328 "0000025325 00000 n \n" 330 "0000025325 00000 n \n"
329 "8 2 \n" 331 "8 2 \n"
330 "0000000000 65535 f \n" 332 "0000000000 65535 f \n"
331 "0000025635 00000 n \n" 333 "0000025635 00000 n \n"
332 "12 1 \n" 334 "12 1 \n"
333 "0000025777 00000 n \n" 335 "0000025777 00000 n \n"
334 "trail"; // Needed to end cross ref table reading. 336 "trail"; // Needed to end cross ref table reading.
335 CPDF_TestParser parser; 337 CPDF_TestParser parser;
336 ASSERT_TRUE( 338 ASSERT_TRUE(
337 parser.InitTestFromBuffer(xref_table, FX_ArraySize(xref_table))); 339 parser.InitTestFromBuffer(xref_table, FX_ArraySize(xref_table)));
338 340
339 ASSERT_TRUE(parser.LoadCrossRefV4(0, 0, FALSE)); 341 ASSERT_TRUE(parser.LoadCrossRefV4(0, 0, FALSE));
340 const FX_FILESIZE offsets[] = {0, 0, 0, 25325, 0, 0, 0, 342 const FX_FILESIZE offsets[] = {0, 0, 0, 25325, 0, 0, 0,
341 0, 0, 25635, 0, 0, 25777}; 343 0, 0, 25635, 0, 0, 25777};
342 const uint8_t types[] = {0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1}; 344 const uint8_t types[] = {0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1};
343 for (size_t i = 0; i < FX_ArraySize(offsets); ++i) 345 for (size_t i = 0; i < FX_ArraySize(offsets); ++i) {
344 EXPECT_EQ(offsets[i], parser.m_ObjectInfo[i].pos); 346 EXPECT_EQ(offsets[i], parser.m_ObjectInfo[i].pos);
345 ASSERT_TRUE(CompareArray(parser.m_V5Type, types, FX_ArraySize(types))); 347 EXPECT_EQ(types[i], parser.m_ObjectInfo[i].type);
348 }
346 } 349 }
347 { 350 {
348 const unsigned char xref_table[] = 351 const unsigned char xref_table[] =
349 "xref \n" 352 "xref \n"
350 "0 7 \n" 353 "0 7 \n"
351 "0000000002 65535 f \n" 354 "0000000002 65535 f \n"
352 "0000000023 00000 n \n" 355 "0000000023 00000 n \n"
353 "0000000003 65535 f \n" 356 "0000000003 65535 f \n"
354 "0000000004 65535 f \n" 357 "0000000004 65535 f \n"
355 "0000000000 65535 f \n" 358 "0000000000 65535 f \n"
356 "0000000045 00000 n \n" 359 "0000000045 00000 n \n"
357 "0000000179 00000 n \n" 360 "0000000179 00000 n \n"
358 "trail"; // Needed to end cross ref table reading. 361 "trail"; // Needed to end cross ref table reading.
359 CPDF_TestParser parser; 362 CPDF_TestParser parser;
360 ASSERT_TRUE( 363 ASSERT_TRUE(
361 parser.InitTestFromBuffer(xref_table, FX_ArraySize(xref_table))); 364 parser.InitTestFromBuffer(xref_table, FX_ArraySize(xref_table)));
362 365
363 ASSERT_TRUE(parser.LoadCrossRefV4(0, 0, FALSE)); 366 ASSERT_TRUE(parser.LoadCrossRefV4(0, 0, FALSE));
364 const FX_FILESIZE offsets[] = {0, 23, 0, 0, 0, 45, 179}; 367 const FX_FILESIZE offsets[] = {0, 23, 0, 0, 0, 45, 179};
365 const uint8_t types[] = {0, 1, 0, 0, 0, 1, 1}; 368 const uint8_t types[] = {0, 1, 0, 0, 0, 1, 1};
366 for (size_t i = 0; i < FX_ArraySize(offsets); ++i) 369 for (size_t i = 0; i < FX_ArraySize(offsets); ++i) {
367 EXPECT_EQ(offsets[i], parser.m_ObjectInfo[i].pos); 370 EXPECT_EQ(offsets[i], parser.m_ObjectInfo[i].pos);
368 ASSERT_TRUE(CompareArray(parser.m_V5Type, types, FX_ArraySize(types))); 371 EXPECT_EQ(types[i], parser.m_ObjectInfo[i].type);
372 }
369 } 373 }
370 } 374 }
OLDNEW
« no previous file with comments | « core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698