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

Side by Side Diff: core/fpdfapi/parser/cpdf_object_unittest.cpp

Issue 2498223005: Make CPDF_Array take unique_ptrs (Closed)
Patch Set: nits Created 4 years, 1 month 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
OLDNEW
1 // Copyright 2016 PDFium Authors. All rights reserved. 1 // Copyright 2016 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/fpdfapi/parser/cpdf_array.h" 5 #include "core/fpdfapi/parser/cpdf_array.h"
6 #include "core/fpdfapi/parser/cpdf_boolean.h" 6 #include "core/fpdfapi/parser/cpdf_boolean.h"
7 #include "core/fpdfapi/parser/cpdf_dictionary.h" 7 #include "core/fpdfapi/parser/cpdf_dictionary.h"
8 #include "core/fpdfapi/parser/cpdf_name.h" 8 #include "core/fpdfapi/parser/cpdf_name.h"
9 #include "core/fpdfapi/parser/cpdf_null.h" 9 #include "core/fpdfapi/parser/cpdf_null.h"
10 #include "core/fpdfapi/parser/cpdf_number.h" 10 #include "core/fpdfapi/parser/cpdf_number.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 // Number objects. 52 // Number objects.
53 CPDF_Number* number_int_obj = new CPDF_Number(1245); 53 CPDF_Number* number_int_obj = new CPDF_Number(1245);
54 CPDF_Number* number_float_obj = new CPDF_Number(9.00345f); 54 CPDF_Number* number_float_obj = new CPDF_Number(9.00345f);
55 // String objects. 55 // String objects.
56 CPDF_String* str_reg_obj = new CPDF_String(L"A simple test"); 56 CPDF_String* str_reg_obj = new CPDF_String(L"A simple test");
57 CPDF_String* str_spec_obj = new CPDF_String(L"\t\n"); 57 CPDF_String* str_spec_obj = new CPDF_String(L"\t\n");
58 // Name object. 58 // Name object.
59 CPDF_Name* name_obj = new CPDF_Name("space"); 59 CPDF_Name* name_obj = new CPDF_Name("space");
60 // Array object. 60 // Array object.
61 m_ArrayObj = new CPDF_Array; 61 m_ArrayObj = new CPDF_Array;
62 m_ArrayObj->InsertAt(0, new CPDF_Number(8902)); 62 m_ArrayObj->InsertNewAt<CPDF_Number>(0, 8902);
63 m_ArrayObj->InsertAt(1, new CPDF_Name("address")); 63 m_ArrayObj->InsertNewAt<CPDF_Name>(1, "address");
64 // Dictionary object. 64 // Dictionary object.
65 m_DictObj = new CPDF_Dictionary(); 65 m_DictObj = new CPDF_Dictionary();
66 m_DictObj->SetFor("bool", new CPDF_Boolean(false)); 66 m_DictObj->SetFor("bool", new CPDF_Boolean(false));
67 m_DictObj->SetFor("num", new CPDF_Number(0.23f)); 67 m_DictObj->SetFor("num", new CPDF_Number(0.23f));
68 // Stream object. 68 // Stream object.
69 const char content[] = "abcdefghijklmnopqrstuvwxyz"; 69 const char content[] = "abcdefghijklmnopqrstuvwxyz";
70 size_t buf_len = FX_ArraySize(content); 70 size_t buf_len = FX_ArraySize(content);
71 uint8_t* buf = reinterpret_cast<uint8_t*>(malloc(buf_len)); 71 uint8_t* buf = reinterpret_cast<uint8_t*>(malloc(buf_len));
72 memcpy(buf, content, buf_len); 72 memcpy(buf, content, buf_len);
73 m_StreamDictObj = new CPDF_Dictionary(); 73 m_StreamDictObj = new CPDF_Dictionary();
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 EXPECT_EQ(m_RefObjs[i].get(), m_RefObjs[i]->AsReference()); 381 EXPECT_EQ(m_RefObjs[i].get(), m_RefObjs[i]->AsReference());
382 } 382 }
383 } 383 }
384 384
385 TEST(PDFArrayTest, GetMatrix) { 385 TEST(PDFArrayTest, GetMatrix) {
386 float elems[][6] = {{0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}, 386 float elems[][6] = {{0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f},
387 {1, 2, 3, 4, 5, 6}, 387 {1, 2, 3, 4, 5, 6},
388 {2.3f, 4.05f, 3, -2, -3, 0.0f}, 388 {2.3f, 4.05f, 3, -2, -3, 0.0f},
389 {0.05f, 0.1f, 0.56f, 0.67f, 1.34f, 99.9f}}; 389 {0.05f, 0.1f, 0.56f, 0.67f, 1.34f, 99.9f}};
390 for (size_t i = 0; i < FX_ArraySize(elems); ++i) { 390 for (size_t i = 0; i < FX_ArraySize(elems); ++i) {
391 std::unique_ptr<CPDF_Array> arr(new CPDF_Array); 391 auto arr = pdfium::MakeUnique<CPDF_Array>();
392 CFX_Matrix matrix(elems[i][0], elems[i][1], elems[i][2], elems[i][3], 392 CFX_Matrix matrix(elems[i][0], elems[i][1], elems[i][2], elems[i][3],
393 elems[i][4], elems[i][5]); 393 elems[i][4], elems[i][5]);
394 for (size_t j = 0; j < 6; ++j) 394 for (size_t j = 0; j < 6; ++j)
395 arr->AddNumber(elems[i][j]); 395 arr->AddNew<CPDF_Number>(elems[i][j]);
396 CFX_Matrix arr_matrix = arr->GetMatrix(); 396 CFX_Matrix arr_matrix = arr->GetMatrix();
397 EXPECT_EQ(matrix.GetA(), arr_matrix.GetA()); 397 EXPECT_EQ(matrix.GetA(), arr_matrix.GetA());
398 EXPECT_EQ(matrix.GetB(), arr_matrix.GetB()); 398 EXPECT_EQ(matrix.GetB(), arr_matrix.GetB());
399 EXPECT_EQ(matrix.GetC(), arr_matrix.GetC()); 399 EXPECT_EQ(matrix.GetC(), arr_matrix.GetC());
400 EXPECT_EQ(matrix.GetD(), arr_matrix.GetD()); 400 EXPECT_EQ(matrix.GetD(), arr_matrix.GetD());
401 EXPECT_EQ(matrix.GetE(), arr_matrix.GetE()); 401 EXPECT_EQ(matrix.GetE(), arr_matrix.GetE());
402 EXPECT_EQ(matrix.GetF(), arr_matrix.GetF()); 402 EXPECT_EQ(matrix.GetF(), arr_matrix.GetF());
403 } 403 }
404 } 404 }
405 405
406 TEST(PDFArrayTest, GetRect) { 406 TEST(PDFArrayTest, GetRect) {
407 float elems[][4] = {{0.0f, 0.0f, 0.0f, 0.0f}, 407 float elems[][4] = {{0.0f, 0.0f, 0.0f, 0.0f},
408 {1, 2, 5, 6}, 408 {1, 2, 5, 6},
409 {2.3f, 4.05f, -3, 0.0f}, 409 {2.3f, 4.05f, -3, 0.0f},
410 {0.05f, 0.1f, 1.34f, 99.9f}}; 410 {0.05f, 0.1f, 1.34f, 99.9f}};
411 for (size_t i = 0; i < FX_ArraySize(elems); ++i) { 411 for (size_t i = 0; i < FX_ArraySize(elems); ++i) {
412 std::unique_ptr<CPDF_Array> arr(new CPDF_Array); 412 auto arr = pdfium::MakeUnique<CPDF_Array>();
413 CFX_FloatRect rect(elems[i]); 413 CFX_FloatRect rect(elems[i]);
414 for (size_t j = 0; j < 4; ++j) 414 for (size_t j = 0; j < 4; ++j)
415 arr->AddNumber(elems[i][j]); 415 arr->AddNew<CPDF_Number>(elems[i][j]);
416 CFX_FloatRect arr_rect = arr->GetRect(); 416 CFX_FloatRect arr_rect = arr->GetRect();
417 EXPECT_EQ(rect.left, arr_rect.left); 417 EXPECT_EQ(rect.left, arr_rect.left);
418 EXPECT_EQ(rect.right, arr_rect.right); 418 EXPECT_EQ(rect.right, arr_rect.right);
419 EXPECT_EQ(rect.bottom, arr_rect.bottom); 419 EXPECT_EQ(rect.bottom, arr_rect.bottom);
420 EXPECT_EQ(rect.top, arr_rect.top); 420 EXPECT_EQ(rect.top, arr_rect.top);
421 } 421 }
422 } 422 }
423 423
424 TEST(PDFArrayTest, GetTypeAt) { 424 TEST(PDFArrayTest, GetTypeAt) {
425 { 425 {
426 // Boolean array. 426 // Boolean array.
427 const bool vals[] = {true, false, false, true, true}; 427 const bool vals[] = {true, false, false, true, true};
428 std::unique_ptr<CPDF_Array> arr(new CPDF_Array); 428 auto arr = pdfium::MakeUnique<CPDF_Array>();
429 for (size_t i = 0; i < FX_ArraySize(vals); ++i) 429 for (size_t i = 0; i < FX_ArraySize(vals); ++i)
430 arr->InsertAt(i, new CPDF_Boolean(vals[i])); 430 arr->InsertNewAt<CPDF_Boolean>(i, vals[i]);
431 for (size_t i = 0; i < FX_ArraySize(vals); ++i) { 431 for (size_t i = 0; i < FX_ArraySize(vals); ++i) {
432 TestArrayAccessors(arr.get(), i, // Array and index. 432 TestArrayAccessors(arr.get(), i, // Array and index.
433 vals[i] ? "true" : "false", // String value. 433 vals[i] ? "true" : "false", // String value.
434 nullptr, // Const string value. 434 nullptr, // Const string value.
435 vals[i] ? 1 : 0, // Integer value. 435 vals[i] ? 1 : 0, // Integer value.
436 0, // Float value. 436 0, // Float value.
437 nullptr, // Array value. 437 nullptr, // Array value.
438 nullptr, // Dictionary value. 438 nullptr, // Dictionary value.
439 nullptr); // Stream value. 439 nullptr); // Stream value.
440 } 440 }
441 } 441 }
442 { 442 {
443 // Integer array. 443 // Integer array.
444 const int vals[] = {10, 0, -345, 2089345456, -1000000000, 567, 93658767}; 444 const int vals[] = {10, 0, -345, 2089345456, -1000000000, 567, 93658767};
445 std::unique_ptr<CPDF_Array> arr(new CPDF_Array); 445 auto arr = pdfium::MakeUnique<CPDF_Array>();
446 for (size_t i = 0; i < FX_ArraySize(vals); ++i) 446 for (size_t i = 0; i < FX_ArraySize(vals); ++i)
447 arr->InsertAt(i, new CPDF_Number(vals[i])); 447 arr->InsertNewAt<CPDF_Number>(i, vals[i]);
448 for (size_t i = 0; i < FX_ArraySize(vals); ++i) { 448 for (size_t i = 0; i < FX_ArraySize(vals); ++i) {
449 char buf[33]; 449 char buf[33];
450 TestArrayAccessors(arr.get(), i, // Array and index. 450 TestArrayAccessors(arr.get(), i, // Array and index.
451 FXSYS_itoa(vals[i], buf, 10), // String value. 451 FXSYS_itoa(vals[i], buf, 10), // String value.
452 nullptr, // Const string value. 452 nullptr, // Const string value.
453 vals[i], // Integer value. 453 vals[i], // Integer value.
454 vals[i], // Float value. 454 vals[i], // Float value.
455 nullptr, // Array value. 455 nullptr, // Array value.
456 nullptr, // Dictionary value. 456 nullptr, // Dictionary value.
457 nullptr); // Stream value. 457 nullptr); // Stream value.
458 } 458 }
459 } 459 }
460 { 460 {
461 // Float array. 461 // Float array.
462 const float vals[] = {0.0f, 0, 10, 10.0f, 0.0345f, 462 const float vals[] = {0.0f, 0, 10, 10.0f, 0.0345f,
463 897.34f, -2.5f, -1.0f, -345.0f, -0.0f}; 463 897.34f, -2.5f, -1.0f, -345.0f, -0.0f};
464 const char* const expected_str[] = { 464 const char* const expected_str[] = {
465 "0", "0", "10", "10", "0.0345", "897.34", "-2.5", "-1", "-345", "0"}; 465 "0", "0", "10", "10", "0.0345", "897.34", "-2.5", "-1", "-345", "0"};
466 std::unique_ptr<CPDF_Array> arr(new CPDF_Array); 466 auto arr = pdfium::MakeUnique<CPDF_Array>();
467 for (size_t i = 0; i < FX_ArraySize(vals); ++i) { 467 for (size_t i = 0; i < FX_ArraySize(vals); ++i)
468 arr->InsertAt(i, new CPDF_Number(vals[i])); 468 arr->InsertNewAt<CPDF_Number>(i, vals[i]);
469 }
470 for (size_t i = 0; i < FX_ArraySize(vals); ++i) { 469 for (size_t i = 0; i < FX_ArraySize(vals); ++i) {
471 TestArrayAccessors(arr.get(), i, // Array and index. 470 TestArrayAccessors(arr.get(), i, // Array and index.
472 expected_str[i], // String value. 471 expected_str[i], // String value.
473 nullptr, // Const string value. 472 nullptr, // Const string value.
474 vals[i], // Integer value. 473 vals[i], // Integer value.
475 vals[i], // Float value. 474 vals[i], // Float value.
476 nullptr, // Array value. 475 nullptr, // Array value.
477 nullptr, // Dictionary value. 476 nullptr, // Dictionary value.
478 nullptr); // Stream value. 477 nullptr); // Stream value.
479 } 478 }
480 } 479 }
481 { 480 {
482 // String and name array 481 // String and name array
483 const char* const vals[] = {"this", "adsde$%^", "\r\t", "\"012", 482 const char* const vals[] = {"this", "adsde$%^", "\r\t", "\"012",
484 ".", "EYREW", "It is a joke :)"}; 483 ".", "EYREW", "It is a joke :)"};
485 std::unique_ptr<CPDF_Array> string_array(new CPDF_Array); 484 std::unique_ptr<CPDF_Array> string_array(new CPDF_Array);
486 std::unique_ptr<CPDF_Array> name_array(new CPDF_Array); 485 std::unique_ptr<CPDF_Array> name_array(new CPDF_Array);
487 for (size_t i = 0; i < FX_ArraySize(vals); ++i) { 486 for (size_t i = 0; i < FX_ArraySize(vals); ++i) {
488 string_array->InsertAt(i, new CPDF_String(vals[i], false)); 487 string_array->InsertNewAt<CPDF_String>(i, vals[i], false);
489 name_array->InsertAt(i, new CPDF_Name(vals[i])); 488 name_array->InsertNewAt<CPDF_Name>(i, vals[i]);
490 } 489 }
491 for (size_t i = 0; i < FX_ArraySize(vals); ++i) { 490 for (size_t i = 0; i < FX_ArraySize(vals); ++i) {
492 TestArrayAccessors(string_array.get(), i, // Array and index. 491 TestArrayAccessors(string_array.get(), i, // Array and index.
493 vals[i], // String value. 492 vals[i], // String value.
494 vals[i], // Const string value. 493 vals[i], // Const string value.
495 0, // Integer value. 494 0, // Integer value.
496 0, // Float value. 495 0, // Float value.
497 nullptr, // Array value. 496 nullptr, // Array value.
498 nullptr, // Dictionary value. 497 nullptr, // Dictionary value.
499 nullptr); // Stream value. 498 nullptr); // Stream value.
500 TestArrayAccessors(name_array.get(), i, // Array and index. 499 TestArrayAccessors(name_array.get(), i, // Array and index.
501 vals[i], // String value. 500 vals[i], // String value.
502 vals[i], // Const string value. 501 vals[i], // Const string value.
503 0, // Integer value. 502 0, // Integer value.
504 0, // Float value. 503 0, // Float value.
505 nullptr, // Array value. 504 nullptr, // Array value.
506 nullptr, // Dictionary value. 505 nullptr, // Dictionary value.
507 nullptr); // Stream value. 506 nullptr); // Stream value.
508 } 507 }
509 } 508 }
510 { 509 {
511 // Null element array. 510 // Null element array.
512 std::unique_ptr<CPDF_Array> arr(new CPDF_Array); 511 auto arr = pdfium::MakeUnique<CPDF_Array>();
513 for (size_t i = 0; i < 3; ++i) 512 for (size_t i = 0; i < 3; ++i)
514 arr->InsertAt(i, new CPDF_Null); 513 arr->InsertNewAt<CPDF_Null>(i);
515 for (size_t i = 0; i < 3; ++i) { 514 for (size_t i = 0; i < 3; ++i) {
516 TestArrayAccessors(arr.get(), i, // Array and index. 515 TestArrayAccessors(arr.get(), i, // Array and index.
517 "", // String value. 516 "", // String value.
518 nullptr, // Const string value. 517 nullptr, // Const string value.
519 0, // Integer value. 518 0, // Integer value.
520 0, // Float value. 519 0, // Float value.
521 nullptr, // Array value. 520 nullptr, // Array value.
522 nullptr, // Dictionary value. 521 nullptr, // Dictionary value.
523 nullptr); // Stream value. 522 nullptr); // Stream value.
524 } 523 }
525 } 524 }
526 { 525 {
527 // Array of array. 526 // Array of array.
528 CPDF_Array* vals[3]; 527 CPDF_Array* vals[3];
529 std::unique_ptr<CPDF_Array> arr(new CPDF_Array); 528 auto arr = pdfium::MakeUnique<CPDF_Array>();
530 for (size_t i = 0; i < 3; ++i) { 529 for (size_t i = 0; i < 3; ++i) {
531 vals[i] = new CPDF_Array; 530 vals[i] = arr->AddNew<CPDF_Array>();
532 for (size_t j = 0; j < 3; ++j) { 531 for (size_t j = 0; j < 3; ++j) {
533 int value = j + 100; 532 int value = j + 100;
534 vals[i]->InsertAt(i, new CPDF_Number(value)); 533 vals[i]->InsertNewAt<CPDF_Number>(i, value);
535 } 534 }
536 arr->InsertAt(i, vals[i]);
537 } 535 }
538 for (size_t i = 0; i < 3; ++i) { 536 for (size_t i = 0; i < 3; ++i) {
539 TestArrayAccessors(arr.get(), i, // Array and index. 537 TestArrayAccessors(arr.get(), i, // Array and index.
540 "", // String value. 538 "", // String value.
541 nullptr, // Const string value. 539 nullptr, // Const string value.
542 0, // Integer value. 540 0, // Integer value.
543 0, // Float value. 541 0, // Float value.
544 vals[i], // Array value. 542 vals[i], // Array value.
545 nullptr, // Dictionary value. 543 nullptr, // Dictionary value.
546 nullptr); // Stream value. 544 nullptr); // Stream value.
547 } 545 }
548 } 546 }
549 { 547 {
550 // Dictionary array. 548 // Dictionary array.
551 CPDF_Dictionary* vals[3]; 549 CPDF_Dictionary* vals[3];
552 std::unique_ptr<CPDF_Array> arr(new CPDF_Array); 550 auto arr = pdfium::MakeUnique<CPDF_Array>();
553 for (size_t i = 0; i < 3; ++i) { 551 for (size_t i = 0; i < 3; ++i) {
554 vals[i] = new CPDF_Dictionary(); 552 vals[i] = arr->AddNew<CPDF_Dictionary>();
555 for (size_t j = 0; j < 3; ++j) { 553 for (size_t j = 0; j < 3; ++j) {
556 std::string key("key"); 554 std::string key("key");
557 char buf[33]; 555 char buf[33];
558 key.append(FXSYS_itoa(j, buf, 10)); 556 key.append(FXSYS_itoa(j, buf, 10));
559 int value = j + 200; 557 int value = j + 200;
560 vals[i]->SetFor(key.c_str(), new CPDF_Number(value)); 558 vals[i]->SetFor(key.c_str(), new CPDF_Number(value));
561 } 559 }
562 arr->InsertAt(i, vals[i]);
563 } 560 }
564 for (size_t i = 0; i < 3; ++i) { 561 for (size_t i = 0; i < 3; ++i) {
565 TestArrayAccessors(arr.get(), i, // Array and index. 562 TestArrayAccessors(arr.get(), i, // Array and index.
566 "", // String value. 563 "", // String value.
567 nullptr, // Const string value. 564 nullptr, // Const string value.
568 0, // Integer value. 565 0, // Integer value.
569 0, // Float value. 566 0, // Float value.
570 nullptr, // Array value. 567 nullptr, // Array value.
571 vals[i], // Dictionary value. 568 vals[i], // Dictionary value.
572 nullptr); // Stream value. 569 nullptr); // Stream value.
573 } 570 }
574 } 571 }
575 { 572 {
576 // Stream array. 573 // Stream array.
577 CPDF_Dictionary* vals[3]; 574 CPDF_Dictionary* vals[3];
578 CPDF_Stream* stream_vals[3]; 575 CPDF_Stream* stream_vals[3];
579 std::unique_ptr<CPDF_Array> arr(new CPDF_Array); 576 auto arr = pdfium::MakeUnique<CPDF_Array>();
580 for (size_t i = 0; i < 3; ++i) { 577 for (size_t i = 0; i < 3; ++i) {
581 vals[i] = new CPDF_Dictionary(); 578 vals[i] = new CPDF_Dictionary();
582 for (size_t j = 0; j < 3; ++j) { 579 for (size_t j = 0; j < 3; ++j) {
583 std::string key("key"); 580 std::string key("key");
584 char buf[33]; 581 char buf[33];
585 key.append(FXSYS_itoa(j, buf, 10)); 582 key.append(FXSYS_itoa(j, buf, 10));
586 int value = j + 200; 583 int value = j + 200;
587 vals[i]->SetFor(key.c_str(), new CPDF_Number(value)); 584 vals[i]->SetFor(key.c_str(), new CPDF_Number(value));
588 } 585 }
589 uint8_t content[] = "content: this is a stream"; 586 uint8_t content[] = "content: this is a stream";
590 size_t data_size = FX_ArraySize(content); 587 size_t data_size = FX_ArraySize(content);
591 uint8_t* data = reinterpret_cast<uint8_t*>(malloc(data_size)); 588 uint8_t* data = reinterpret_cast<uint8_t*>(malloc(data_size));
592 memcpy(data, content, data_size); 589 memcpy(data, content, data_size);
593 stream_vals[i] = new CPDF_Stream(data, data_size, vals[i]); 590 stream_vals[i] = arr->AddNew<CPDF_Stream>(data, data_size, vals[i]);
594 arr->InsertAt(i, stream_vals[i]);
595 } 591 }
596 for (size_t i = 0; i < 3; ++i) { 592 for (size_t i = 0; i < 3; ++i) {
597 TestArrayAccessors(arr.get(), i, // Array and index. 593 TestArrayAccessors(arr.get(), i, // Array and index.
598 "", // String value. 594 "", // String value.
599 nullptr, // Const string value. 595 nullptr, // Const string value.
600 0, // Integer value. 596 0, // Integer value.
601 0, // Float value. 597 0, // Float value.
602 nullptr, // Array value. 598 nullptr, // Array value.
603 vals[i], // Dictionary value. 599 vals[i], // Dictionary value.
604 stream_vals[i]); // Stream value. 600 stream_vals[i]); // Stream value.
605 } 601 }
606 } 602 }
607 { 603 {
608 // Mixed array. 604 // Mixed array.
609 std::unique_ptr<CPDF_Array> arr(new CPDF_Array); 605 auto arr = pdfium::MakeUnique<CPDF_Array>();
610 // Array arr will take ownership of all the objects inserted. 606 arr->InsertNewAt<CPDF_Boolean>(0, true);
611 arr->InsertAt(0, new CPDF_Boolean(true)); 607 arr->InsertNewAt<CPDF_Boolean>(1, false);
612 arr->InsertAt(1, new CPDF_Boolean(false)); 608 arr->InsertNewAt<CPDF_Number>(2, 0);
613 arr->InsertAt(2, new CPDF_Number(0)); 609 arr->InsertNewAt<CPDF_Number>(3, -1234);
614 arr->InsertAt(3, new CPDF_Number(-1234)); 610 arr->InsertNewAt<CPDF_Number>(4, 2345.0f);
615 arr->InsertAt(4, new CPDF_Number(2345.0f)); 611 arr->InsertNewAt<CPDF_Number>(5, 0.05f);
616 arr->InsertAt(5, new CPDF_Number(0.05f)); 612 arr->InsertNewAt<CPDF_String>(6, "", false);
617 arr->InsertAt(6, new CPDF_String("", false)); 613 arr->InsertNewAt<CPDF_String>(7, "It is a test!", false);
618 arr->InsertAt(7, new CPDF_String("It is a test!", false)); 614 arr->InsertNewAt<CPDF_Name>(8, "NAME");
619 arr->InsertAt(8, new CPDF_Name("NAME")); 615 arr->InsertNewAt<CPDF_Name>(9, "test");
620 arr->InsertAt(9, new CPDF_Name("test")); 616 arr->InsertNewAt<CPDF_Null>(10);
621 arr->InsertAt(10, new CPDF_Null()); 617
622 CPDF_Array* arr_val = new CPDF_Array; 618 CPDF_Array* arr_val = arr->InsertNewAt<CPDF_Array>(11);
623 arr_val->AddNumber(1); 619 arr_val->AddNew<CPDF_Number>(1);
624 arr_val->AddNumber(2); 620 arr_val->AddNew<CPDF_Number>(2);
625 arr->InsertAt(11, arr_val); 621
626 CPDF_Dictionary* dict_val = new CPDF_Dictionary(); 622 CPDF_Dictionary* dict_val = arr->InsertNewAt<CPDF_Dictionary>(12);
627 dict_val->SetFor("key1", new CPDF_String("Linda", false)); 623 dict_val->SetFor("key1", new CPDF_String("Linda", false));
628 dict_val->SetFor("key2", new CPDF_String("Zoe", false)); 624 dict_val->SetFor("key2", new CPDF_String("Zoe", false));
629 arr->InsertAt(12, dict_val); 625
630 CPDF_Dictionary* stream_dict = new CPDF_Dictionary(); 626 CPDF_Dictionary* stream_dict = new CPDF_Dictionary();
631 stream_dict->SetFor("key1", new CPDF_String("John", false)); 627 stream_dict->SetFor("key1", new CPDF_String("John", false));
632 stream_dict->SetFor("key2", new CPDF_String("King", false)); 628 stream_dict->SetFor("key2", new CPDF_String("King", false));
633 uint8_t data[] = "A stream for test"; 629 uint8_t data[] = "A stream for test";
634 // The data buffer will be owned by stream object, so it needs to be 630 // The data buffer will be owned by stream object, so it needs to be
635 // dynamically allocated. 631 // dynamically allocated.
636 size_t buf_size = sizeof(data); 632 size_t buf_size = sizeof(data);
637 uint8_t* buf = reinterpret_cast<uint8_t*>(malloc(buf_size)); 633 uint8_t* buf = reinterpret_cast<uint8_t*>(malloc(buf_size));
638 memcpy(buf, data, buf_size); 634 memcpy(buf, data, buf_size);
639 CPDF_Stream* stream_val = new CPDF_Stream(buf, buf_size, stream_dict); 635 CPDF_Stream* stream_val =
640 arr->InsertAt(13, stream_val); 636 arr->InsertNewAt<CPDF_Stream>(13, buf, buf_size, stream_dict);
641 const char* const expected_str[] = { 637 const char* const expected_str[] = {
642 "true", "false", "0", "-1234", "2345", "0.05", "", 638 "true", "false", "0", "-1234", "2345", "0.05", "",
643 "It is a test!", "NAME", "test", "", "", "", ""}; 639 "It is a test!", "NAME", "test", "", "", "", ""};
644 const int expected_int[] = {1, 0, 0, -1234, 2345, 0, 0, 640 const int expected_int[] = {1, 0, 0, -1234, 2345, 0, 0,
645 0, 0, 0, 0, 0, 0, 0}; 641 0, 0, 0, 0, 0, 0, 0};
646 const float expected_float[] = {0, 0, 0, -1234, 2345, 0.05f, 0, 642 const float expected_float[] = {0, 0, 0, -1234, 2345, 0.05f, 0,
647 0, 0, 0, 0, 0, 0, 0}; 643 0, 0, 0, 0, 0, 0, 0};
648 for (size_t i = 0; i < arr->GetCount(); ++i) { 644 for (size_t i = 0; i < arr->GetCount(); ++i) {
649 EXPECT_STREQ(expected_str[i], arr->GetStringAt(i).c_str()); 645 EXPECT_STREQ(expected_str[i], arr->GetStringAt(i).c_str());
650 EXPECT_EQ(expected_int[i], arr->GetIntegerAt(i)); 646 EXPECT_EQ(expected_int[i], arr->GetIntegerAt(i));
(...skipping 13 matching lines...) Expand all
664 else 660 else
665 EXPECT_EQ(nullptr, arr->GetDictAt(i)); 661 EXPECT_EQ(nullptr, arr->GetDictAt(i));
666 } 662 }
667 } 663 }
668 } 664 }
669 } 665 }
670 666
671 TEST(PDFArrayTest, AddNumber) { 667 TEST(PDFArrayTest, AddNumber) {
672 float vals[] = {1.0f, -1.0f, 0, 0.456734f, 668 float vals[] = {1.0f, -1.0f, 0, 0.456734f,
673 12345.54321f, 0.5f, 1000, 0.000045f}; 669 12345.54321f, 0.5f, 1000, 0.000045f};
674 std::unique_ptr<CPDF_Array> arr(new CPDF_Array); 670 auto arr = pdfium::MakeUnique<CPDF_Array>();
675 for (size_t i = 0; i < FX_ArraySize(vals); ++i) 671 for (size_t i = 0; i < FX_ArraySize(vals); ++i)
676 arr->AddNumber(vals[i]); 672 arr->AddNew<CPDF_Number>(vals[i]);
677 for (size_t i = 0; i < FX_ArraySize(vals); ++i) { 673 for (size_t i = 0; i < FX_ArraySize(vals); ++i) {
678 EXPECT_EQ(CPDF_Object::NUMBER, arr->GetObjectAt(i)->GetType()); 674 EXPECT_EQ(CPDF_Object::NUMBER, arr->GetObjectAt(i)->GetType());
679 EXPECT_EQ(vals[i], arr->GetObjectAt(i)->GetNumber()); 675 EXPECT_EQ(vals[i], arr->GetObjectAt(i)->GetNumber());
680 } 676 }
681 } 677 }
682 678
683 TEST(PDFArrayTest, AddInteger) { 679 TEST(PDFArrayTest, AddInteger) {
684 int vals[] = {0, 1, 934435456, 876, 10000, -1, -24354656, -100}; 680 int vals[] = {0, 1, 934435456, 876, 10000, -1, -24354656, -100};
685 std::unique_ptr<CPDF_Array> arr(new CPDF_Array); 681 auto arr = pdfium::MakeUnique<CPDF_Array>();
686 for (size_t i = 0; i < FX_ArraySize(vals); ++i) 682 for (size_t i = 0; i < FX_ArraySize(vals); ++i)
687 arr->AddInteger(vals[i]); 683 arr->AddNew<CPDF_Number>(vals[i]);
688 for (size_t i = 0; i < FX_ArraySize(vals); ++i) { 684 for (size_t i = 0; i < FX_ArraySize(vals); ++i) {
689 EXPECT_EQ(CPDF_Object::NUMBER, arr->GetObjectAt(i)->GetType()); 685 EXPECT_EQ(CPDF_Object::NUMBER, arr->GetObjectAt(i)->GetType());
690 EXPECT_EQ(vals[i], arr->GetObjectAt(i)->GetNumber()); 686 EXPECT_EQ(vals[i], arr->GetObjectAt(i)->GetNumber());
691 } 687 }
692 } 688 }
693 689
694 TEST(PDFArrayTest, AddStringAndName) { 690 TEST(PDFArrayTest, AddStringAndName) {
695 const char* vals[] = {"", "a", "ehjhRIOYTTFdfcdnv", "122323", 691 const char* vals[] = {"", "a", "ehjhRIOYTTFdfcdnv", "122323",
696 "$#%^&**", " ", "This is a test.\r\n"}; 692 "$#%^&**", " ", "This is a test.\r\n"};
697 std::unique_ptr<CPDF_Array> string_array(new CPDF_Array); 693 std::unique_ptr<CPDF_Array> string_array(new CPDF_Array);
698 std::unique_ptr<CPDF_Array> name_array(new CPDF_Array); 694 std::unique_ptr<CPDF_Array> name_array(new CPDF_Array);
699 for (size_t i = 0; i < FX_ArraySize(vals); ++i) { 695 for (size_t i = 0; i < FX_ArraySize(vals); ++i) {
700 string_array->AddString(vals[i]); 696 string_array->AddNew<CPDF_String>(vals[i], false);
701 name_array->AddName(vals[i]); 697 name_array->AddNew<CPDF_Name>(vals[i]);
702 } 698 }
703 for (size_t i = 0; i < FX_ArraySize(vals); ++i) { 699 for (size_t i = 0; i < FX_ArraySize(vals); ++i) {
704 EXPECT_EQ(CPDF_Object::STRING, string_array->GetObjectAt(i)->GetType()); 700 EXPECT_EQ(CPDF_Object::STRING, string_array->GetObjectAt(i)->GetType());
705 EXPECT_STREQ(vals[i], string_array->GetObjectAt(i)->GetString().c_str()); 701 EXPECT_STREQ(vals[i], string_array->GetObjectAt(i)->GetString().c_str());
706 EXPECT_EQ(CPDF_Object::NAME, name_array->GetObjectAt(i)->GetType()); 702 EXPECT_EQ(CPDF_Object::NAME, name_array->GetObjectAt(i)->GetType());
707 EXPECT_STREQ(vals[i], name_array->GetObjectAt(i)->GetString().c_str()); 703 EXPECT_STREQ(vals[i], name_array->GetObjectAt(i)->GetString().c_str());
708 } 704 }
709 } 705 }
710 706
711 TEST(PDFArrayTest, AddReferenceAndGetObjectAt) { 707 TEST(PDFArrayTest, AddReferenceAndGetObjectAt) {
712 std::unique_ptr<CPDF_IndirectObjectHolder> holder( 708 std::unique_ptr<CPDF_IndirectObjectHolder> holder(
713 new CPDF_IndirectObjectHolder()); 709 new CPDF_IndirectObjectHolder());
714 CPDF_Boolean* boolean_obj = new CPDF_Boolean(true); 710 CPDF_Boolean* boolean_obj = new CPDF_Boolean(true);
715 CPDF_Number* int_obj = new CPDF_Number(-1234); 711 CPDF_Number* int_obj = new CPDF_Number(-1234);
716 CPDF_Number* float_obj = new CPDF_Number(2345.089f); 712 CPDF_Number* float_obj = new CPDF_Number(2345.089f);
717 CPDF_String* str_obj = new CPDF_String("Adsfdsf 343434 %&&*\n", false); 713 CPDF_String* str_obj = new CPDF_String("Adsfdsf 343434 %&&*\n", false);
718 CPDF_Name* name_obj = new CPDF_Name("Title:"); 714 CPDF_Name* name_obj = new CPDF_Name("Title:");
719 CPDF_Null* null_obj = new CPDF_Null(); 715 CPDF_Null* null_obj = new CPDF_Null();
720 CPDF_Object* indirect_objs[] = {boolean_obj, int_obj, float_obj, 716 CPDF_Object* indirect_objs[] = {boolean_obj, int_obj, float_obj,
721 str_obj, name_obj, null_obj}; 717 str_obj, name_obj, null_obj};
722 unsigned int obj_nums[] = {2, 4, 7, 2345, 799887, 1}; 718 unsigned int obj_nums[] = {2, 4, 7, 2345, 799887, 1};
723 std::unique_ptr<CPDF_Array> arr(new CPDF_Array); 719 auto arr = pdfium::MakeUnique<CPDF_Array>();
724 std::unique_ptr<CPDF_Array> arr1(new CPDF_Array); 720 std::unique_ptr<CPDF_Array> arr1(new CPDF_Array);
725 // Create two arrays of references by different AddReference() APIs. 721 // Create two arrays of references by different AddReference() APIs.
726 for (size_t i = 0; i < FX_ArraySize(indirect_objs); ++i) { 722 for (size_t i = 0; i < FX_ArraySize(indirect_objs); ++i) {
727 holder->ReplaceIndirectObjectIfHigherGeneration( 723 holder->ReplaceIndirectObjectIfHigherGeneration(
728 obj_nums[i], pdfium::WrapUnique<CPDF_Object>(indirect_objs[i])); 724 obj_nums[i], pdfium::WrapUnique<CPDF_Object>(indirect_objs[i]));
729 arr->AddReference(holder.get(), obj_nums[i]); 725 arr->AddNew<CPDF_Reference>(holder.get(), obj_nums[i]);
730 arr1->AddReference(holder.get(), indirect_objs[i]->GetObjNum()); 726 arr1->AddNew<CPDF_Reference>(holder.get(), indirect_objs[i]->GetObjNum());
731 } 727 }
732 // Check indirect objects. 728 // Check indirect objects.
733 for (size_t i = 0; i < FX_ArraySize(obj_nums); ++i) 729 for (size_t i = 0; i < FX_ArraySize(obj_nums); ++i)
734 EXPECT_EQ(indirect_objs[i], holder->GetOrParseIndirectObject(obj_nums[i])); 730 EXPECT_EQ(indirect_objs[i], holder->GetOrParseIndirectObject(obj_nums[i]));
735 // Check arrays. 731 // Check arrays.
736 EXPECT_EQ(arr->GetCount(), arr1->GetCount()); 732 EXPECT_EQ(arr->GetCount(), arr1->GetCount());
737 for (size_t i = 0; i < arr->GetCount(); ++i) { 733 for (size_t i = 0; i < arr->GetCount(); ++i) {
738 EXPECT_EQ(CPDF_Object::REFERENCE, arr->GetObjectAt(i)->GetType()); 734 EXPECT_EQ(CPDF_Object::REFERENCE, arr->GetObjectAt(i)->GetType());
739 EXPECT_EQ(indirect_objs[i], arr->GetObjectAt(i)->GetDirect()); 735 EXPECT_EQ(indirect_objs[i], arr->GetObjectAt(i)->GetDirect());
740 EXPECT_EQ(indirect_objs[i], arr->GetDirectObjectAt(i)); 736 EXPECT_EQ(indirect_objs[i], arr->GetDirectObjectAt(i));
741 EXPECT_EQ(CPDF_Object::REFERENCE, arr1->GetObjectAt(i)->GetType()); 737 EXPECT_EQ(CPDF_Object::REFERENCE, arr1->GetObjectAt(i)->GetType());
742 EXPECT_EQ(indirect_objs[i], arr1->GetObjectAt(i)->GetDirect()); 738 EXPECT_EQ(indirect_objs[i], arr1->GetObjectAt(i)->GetDirect());
743 EXPECT_EQ(indirect_objs[i], arr1->GetDirectObjectAt(i)); 739 EXPECT_EQ(indirect_objs[i], arr1->GetDirectObjectAt(i));
744 } 740 }
745 } 741 }
746 742
747 TEST(PDFArrayTest, CloneDirectObject) { 743 TEST(PDFArrayTest, CloneDirectObject) {
748 CPDF_IndirectObjectHolder objects_holder; 744 CPDF_IndirectObjectHolder objects_holder;
749 std::unique_ptr<CPDF_Array> array(new CPDF_Array); 745 std::unique_ptr<CPDF_Array> array(new CPDF_Array);
750 array->AddReference(&objects_holder, 1234); 746 array->AddNew<CPDF_Reference>(&objects_holder, 1234);
751 ASSERT_EQ(1U, array->GetCount()); 747 ASSERT_EQ(1U, array->GetCount());
752 CPDF_Object* obj = array->GetObjectAt(0); 748 CPDF_Object* obj = array->GetObjectAt(0);
753 ASSERT_TRUE(obj); 749 ASSERT_TRUE(obj);
754 EXPECT_TRUE(obj->IsReference()); 750 EXPECT_TRUE(obj->IsReference());
755 751
756 std::unique_ptr<CPDF_Object> cloned_array_object = array->CloneDirectObject(); 752 std::unique_ptr<CPDF_Object> cloned_array_object = array->CloneDirectObject();
757 ASSERT_TRUE(cloned_array_object); 753 ASSERT_TRUE(cloned_array_object);
758 ASSERT_TRUE(cloned_array_object->IsArray()); 754 ASSERT_TRUE(cloned_array_object->IsArray());
759 755
760 std::unique_ptr<CPDF_Array> cloned_array = 756 std::unique_ptr<CPDF_Array> cloned_array =
761 ToArray(std::move(cloned_array_object)); 757 ToArray(std::move(cloned_array_object));
762 ASSERT_EQ(1U, cloned_array->GetCount()); 758 ASSERT_EQ(1U, cloned_array->GetCount());
763 CPDF_Object* cloned_obj = cloned_array->GetObjectAt(0); 759 CPDF_Object* cloned_obj = cloned_array->GetObjectAt(0);
764 EXPECT_FALSE(cloned_obj); 760 EXPECT_FALSE(cloned_obj);
765 } 761 }
766 762
767 TEST(PDFArrayTest, ConvertIndirect) { 763 TEST(PDFArrayTest, ConvertIndirect) {
768 CPDF_IndirectObjectHolder objects_holder; 764 CPDF_IndirectObjectHolder objects_holder;
769 std::unique_ptr<CPDF_Array> array(new CPDF_Array); 765 auto array = pdfium::MakeUnique<CPDF_Array>();
770 CPDF_Object* pObj = new CPDF_Number(42); 766 CPDF_Object* pObj = array->AddNew<CPDF_Number>(42);
771 array->Add(pObj);
772 array->ConvertToIndirectObjectAt(0, &objects_holder); 767 array->ConvertToIndirectObjectAt(0, &objects_holder);
773 CPDF_Object* pRef = array->GetObjectAt(0); 768 CPDF_Object* pRef = array->GetObjectAt(0);
774 CPDF_Object* pNum = array->GetDirectObjectAt(0); 769 CPDF_Object* pNum = array->GetDirectObjectAt(0);
775 EXPECT_TRUE(pRef->IsReference()); 770 EXPECT_TRUE(pRef->IsReference());
776 EXPECT_TRUE(pNum->IsNumber()); 771 EXPECT_TRUE(pNum->IsNumber());
777 EXPECT_NE(pObj, pRef); 772 EXPECT_NE(pObj, pRef);
778 EXPECT_EQ(pObj, pNum); 773 EXPECT_EQ(pObj, pNum);
779 EXPECT_EQ(42, array->GetIntegerAt(0)); 774 EXPECT_EQ(42, array->GetIntegerAt(0));
780 } 775 }
781 776
(...skipping 13 matching lines...) Expand all
795 std::unique_ptr<CPDF_Dictionary> cloned_dict = 790 std::unique_ptr<CPDF_Dictionary> cloned_dict =
796 ToDictionary(std::move(cloned_dict_object)); 791 ToDictionary(std::move(cloned_dict_object));
797 ASSERT_EQ(1U, cloned_dict->GetCount()); 792 ASSERT_EQ(1U, cloned_dict->GetCount());
798 CPDF_Object* cloned_obj = cloned_dict->GetObjectFor("foo"); 793 CPDF_Object* cloned_obj = cloned_dict->GetObjectFor("foo");
799 EXPECT_FALSE(cloned_obj); 794 EXPECT_FALSE(cloned_obj);
800 } 795 }
801 796
802 TEST(PDFObjectTest, CloneCheckLoop) { 797 TEST(PDFObjectTest, CloneCheckLoop) {
803 { 798 {
804 // Create a dictionary/array pair with a reference loop. 799 // Create a dictionary/array pair with a reference loop.
805 CPDF_Dictionary* dict_obj = new CPDF_Dictionary(); 800 auto arr_obj = pdfium::MakeUnique<CPDF_Array>();
806 std::unique_ptr<CPDF_Array> arr_obj(new CPDF_Array); 801 CPDF_Dictionary* dict_obj = arr_obj->InsertNewAt<CPDF_Dictionary>(0);
807 dict_obj->SetFor("arr", arr_obj.get()); 802 dict_obj->SetFor("arr", arr_obj.get());
808 arr_obj->InsertAt(0, dict_obj);
809
810 // Clone this object to see whether stack overflow will be triggered. 803 // Clone this object to see whether stack overflow will be triggered.
811 std::unique_ptr<CPDF_Array> cloned_array = ToArray(arr_obj->Clone()); 804 std::unique_ptr<CPDF_Array> cloned_array = ToArray(arr_obj->Clone());
812 // Cloned object should be the same as the original. 805 // Cloned object should be the same as the original.
813 ASSERT_TRUE(cloned_array); 806 ASSERT_TRUE(cloned_array);
814 EXPECT_EQ(1u, cloned_array->GetCount()); 807 EXPECT_EQ(1u, cloned_array->GetCount());
815 CPDF_Object* cloned_dict = cloned_array->GetObjectAt(0); 808 CPDF_Object* cloned_dict = cloned_array->GetObjectAt(0);
816 ASSERT_TRUE(cloned_dict); 809 ASSERT_TRUE(cloned_dict);
817 ASSERT_TRUE(cloned_dict->IsDictionary()); 810 ASSERT_TRUE(cloned_dict->IsDictionary());
818 // Recursively referenced object is not cloned. 811 // Recursively referenced object is not cloned.
819 EXPECT_EQ(nullptr, cloned_dict->AsDictionary()->GetObjectFor("arr")); 812 EXPECT_EQ(nullptr, cloned_dict->AsDictionary()->GetObjectFor("arr"));
(...skipping 13 matching lines...) Expand all
833 ASSERT_TRUE(cloned_dict); 826 ASSERT_TRUE(cloned_dict);
834 ASSERT_TRUE(cloned_dict->IsDictionary()); 827 ASSERT_TRUE(cloned_dict->IsDictionary());
835 // Recursively referenced object is not cloned. 828 // Recursively referenced object is not cloned.
836 EXPECT_EQ(nullptr, cloned_dict->AsDictionary()->GetObjectFor("stream")); 829 EXPECT_EQ(nullptr, cloned_dict->AsDictionary()->GetObjectFor("stream"));
837 } 830 }
838 { 831 {
839 CPDF_IndirectObjectHolder objects_holder; 832 CPDF_IndirectObjectHolder objects_holder;
840 // Create an object with a reference loop. 833 // Create an object with a reference loop.
841 CPDF_Dictionary* dict_obj = objects_holder.NewIndirect<CPDF_Dictionary>(); 834 CPDF_Dictionary* dict_obj = objects_holder.NewIndirect<CPDF_Dictionary>();
842 std::unique_ptr<CPDF_Array> arr_obj = pdfium::MakeUnique<CPDF_Array>(); 835 std::unique_ptr<CPDF_Array> arr_obj = pdfium::MakeUnique<CPDF_Array>();
843 arr_obj->InsertAt( 836 arr_obj->InsertNewAt<CPDF_Reference>(0, &objects_holder,
844 0, new CPDF_Reference(&objects_holder, dict_obj->GetObjNum())); 837 dict_obj->GetObjNum());
845 CPDF_Object* elem0 = arr_obj->GetObjectAt(0); 838 CPDF_Object* elem0 = arr_obj->GetObjectAt(0);
846 dict_obj->SetFor("arr", arr_obj.release()); 839 dict_obj->SetFor("arr", arr_obj.release());
847 EXPECT_EQ(1u, dict_obj->GetObjNum()); 840 EXPECT_EQ(1u, dict_obj->GetObjNum());
848 ASSERT_TRUE(elem0); 841 ASSERT_TRUE(elem0);
849 ASSERT_TRUE(elem0->IsReference()); 842 ASSERT_TRUE(elem0->IsReference());
850 EXPECT_EQ(1u, elem0->AsReference()->GetRefObjNum()); 843 EXPECT_EQ(1u, elem0->AsReference()->GetRefObjNum());
851 EXPECT_EQ(dict_obj, elem0->AsReference()->GetDirect()); 844 EXPECT_EQ(dict_obj, elem0->AsReference()->GetDirect());
852 845
853 // Clone this object to see whether stack overflow will be triggered. 846 // Clone this object to see whether stack overflow will be triggered.
854 std::unique_ptr<CPDF_Dictionary> cloned_dict = 847 std::unique_ptr<CPDF_Dictionary> cloned_dict =
(...skipping 16 matching lines...) Expand all
871 dict->SetFor("clams", pObj); 864 dict->SetFor("clams", pObj);
872 dict->ConvertToIndirectObjectFor("clams", &objects_holder); 865 dict->ConvertToIndirectObjectFor("clams", &objects_holder);
873 CPDF_Object* pRef = dict->GetObjectFor("clams"); 866 CPDF_Object* pRef = dict->GetObjectFor("clams");
874 CPDF_Object* pNum = dict->GetDirectObjectFor("clams"); 867 CPDF_Object* pNum = dict->GetDirectObjectFor("clams");
875 EXPECT_TRUE(pRef->IsReference()); 868 EXPECT_TRUE(pRef->IsReference());
876 EXPECT_TRUE(pNum->IsNumber()); 869 EXPECT_TRUE(pNum->IsNumber());
877 EXPECT_NE(pObj, pRef); 870 EXPECT_NE(pObj, pRef);
878 EXPECT_EQ(pObj, pNum); 871 EXPECT_EQ(pObj, pNum);
879 EXPECT_EQ(42, dict->GetIntegerFor("clams")); 872 EXPECT_EQ(42, dict->GetIntegerFor("clams"));
880 } 873 }
OLDNEW
« no previous file with comments | « core/fpdfapi/parser/cpdf_document_unittest.cpp ('k') | core/fpdfapi/parser/cpdf_syntax_parser.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698