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

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

Issue 1889863002: Make CPDF_Dictionary methods take CFX_ByteString arguments (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: One last caller. Created 4 years, 8 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/fpdfapi/fpdf_parser/cpdf_dictionary.cpp ('k') | core/fpdfapi/fpdf_parser/cpdf_parser.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/fpdf_parser/cpdf_boolean.h" 5 #include "core/fpdfapi/fpdf_parser/cpdf_boolean.h"
6 #include "core/fpdfapi/fpdf_parser/cpdf_null.h" 6 #include "core/fpdfapi/fpdf_parser/cpdf_null.h"
7 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" 7 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h"
8 #include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h" 8 #include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h"
9 #include "core/fpdfapi/fpdf_parser/include/cpdf_name.h" 9 #include "core/fpdfapi/fpdf_parser/include/cpdf_name.h"
10 #include "core/fpdfapi/fpdf_parser/include/cpdf_number.h" 10 #include "core/fpdfapi/fpdf_parser/include/cpdf_number.h"
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 } 127 }
128 return true; 128 return true;
129 } 129 }
130 case CPDF_Object::DICTIONARY: { 130 case CPDF_Object::DICTIONARY: {
131 const CPDF_Dictionary* dict1 = obj1->AsDictionary(); 131 const CPDF_Dictionary* dict1 = obj1->AsDictionary();
132 const CPDF_Dictionary* dict2 = obj2->AsDictionary(); 132 const CPDF_Dictionary* dict2 = obj2->AsDictionary();
133 if (dict1->GetCount() != dict2->GetCount()) 133 if (dict1->GetCount() != dict2->GetCount())
134 return false; 134 return false;
135 for (CPDF_Dictionary::const_iterator it = dict1->begin(); 135 for (CPDF_Dictionary::const_iterator it = dict1->begin();
136 it != dict1->end(); ++it) { 136 it != dict1->end(); ++it) {
137 if (!Equal(it->second, dict2->GetObjectBy(it->first.AsStringC()))) 137 if (!Equal(it->second, dict2->GetObjectBy(it->first)))
138 return false; 138 return false;
139 } 139 }
140 return true; 140 return true;
141 } 141 }
142 case CPDF_Object::NULLOBJ: 142 case CPDF_Object::NULLOBJ:
143 return true; 143 return true;
144 case CPDF_Object::STREAM: { 144 case CPDF_Object::STREAM: {
145 const CPDF_Stream* stream1 = obj1->AsStream(); 145 const CPDF_Stream* stream1 = obj1->AsStream();
146 const CPDF_Stream* stream2 = obj2->AsStream(); 146 const CPDF_Stream* stream2 = obj2->AsStream();
147 if (!stream1->GetDict() && !stream2->GetDict()) 147 if (!stream1->GetDict() && !stream2->GetDict())
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
549 // Dictionary array. 549 // Dictionary array.
550 CPDF_Dictionary* vals[3]; 550 CPDF_Dictionary* vals[3];
551 ScopedArray arr(new CPDF_Array); 551 ScopedArray arr(new CPDF_Array);
552 for (size_t i = 0; i < 3; ++i) { 552 for (size_t i = 0; i < 3; ++i) {
553 vals[i] = new CPDF_Dictionary; 553 vals[i] = new CPDF_Dictionary;
554 for (size_t j = 0; j < 3; ++j) { 554 for (size_t j = 0; j < 3; ++j) {
555 std::string key("key"); 555 std::string key("key");
556 char buf[33]; 556 char buf[33];
557 key.append(FXSYS_itoa(j, buf, 10)); 557 key.append(FXSYS_itoa(j, buf, 10));
558 int value = j + 200; 558 int value = j + 200;
559 vals[i]->SetAt(CFX_ByteStringC(key.c_str()), new CPDF_Number(value)); 559 vals[i]->SetAt(key.c_str(), new CPDF_Number(value));
560 } 560 }
561 arr->InsertAt(i, vals[i]); 561 arr->InsertAt(i, vals[i]);
562 } 562 }
563 for (size_t i = 0; i < 3; ++i) { 563 for (size_t i = 0; i < 3; ++i) {
564 TestArrayAccessors(arr.get(), i, // Array and index. 564 TestArrayAccessors(arr.get(), i, // Array and index.
565 "", // String value. 565 "", // String value.
566 nullptr, // Const string value. 566 nullptr, // Const string value.
567 0, // Integer value. 567 0, // Integer value.
568 0, // Float value. 568 0, // Float value.
569 nullptr, // Array value. 569 nullptr, // Array value.
570 vals[i], // Dictionary value. 570 vals[i], // Dictionary value.
571 nullptr); // Stream value. 571 nullptr); // Stream value.
572 } 572 }
573 } 573 }
574 { 574 {
575 // Stream array. 575 // Stream array.
576 CPDF_Dictionary* vals[3]; 576 CPDF_Dictionary* vals[3];
577 CPDF_Stream* stream_vals[3]; 577 CPDF_Stream* stream_vals[3];
578 ScopedArray arr(new CPDF_Array); 578 ScopedArray arr(new CPDF_Array);
579 for (size_t i = 0; i < 3; ++i) { 579 for (size_t i = 0; i < 3; ++i) {
580 vals[i] = new CPDF_Dictionary; 580 vals[i] = new CPDF_Dictionary;
581 for (size_t j = 0; j < 3; ++j) { 581 for (size_t j = 0; j < 3; ++j) {
582 std::string key("key"); 582 std::string key("key");
583 char buf[33]; 583 char buf[33];
584 key.append(FXSYS_itoa(j, buf, 10)); 584 key.append(FXSYS_itoa(j, buf, 10));
585 int value = j + 200; 585 int value = j + 200;
586 vals[i]->SetAt(CFX_ByteStringC(key.c_str()), new CPDF_Number(value)); 586 vals[i]->SetAt(key.c_str(), new CPDF_Number(value));
587 } 587 }
588 uint8_t content[] = "content: this is a stream"; 588 uint8_t content[] = "content: this is a stream";
589 size_t data_size = FX_ArraySize(content); 589 size_t data_size = FX_ArraySize(content);
590 uint8_t* data = reinterpret_cast<uint8_t*>(malloc(data_size)); 590 uint8_t* data = reinterpret_cast<uint8_t*>(malloc(data_size));
591 memcpy(data, content, data_size); 591 memcpy(data, content, data_size);
592 stream_vals[i] = new CPDF_Stream(data, data_size, vals[i]); 592 stream_vals[i] = new CPDF_Stream(data, data_size, vals[i]);
593 arr->InsertAt(i, stream_vals[i]); 593 arr->InsertAt(i, stream_vals[i]);
594 } 594 }
595 for (size_t i = 0; i < 3; ++i) { 595 for (size_t i = 0; i < 3; ++i) {
596 TestArrayAccessors(arr.get(), i, // Array and index. 596 TestArrayAccessors(arr.get(), i, // Array and index.
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
735 EXPECT_EQ(arr->GetCount(), arr1->GetCount()); 735 EXPECT_EQ(arr->GetCount(), arr1->GetCount());
736 for (size_t i = 0; i < arr->GetCount(); ++i) { 736 for (size_t i = 0; i < arr->GetCount(); ++i) {
737 EXPECT_EQ(CPDF_Object::REFERENCE, arr->GetObjectAt(i)->GetType()); 737 EXPECT_EQ(CPDF_Object::REFERENCE, arr->GetObjectAt(i)->GetType());
738 EXPECT_EQ(indirect_objs[i], arr->GetObjectAt(i)->GetDirect()); 738 EXPECT_EQ(indirect_objs[i], arr->GetObjectAt(i)->GetDirect());
739 EXPECT_EQ(indirect_objs[i], arr->GetDirectObjectAt(i)); 739 EXPECT_EQ(indirect_objs[i], arr->GetDirectObjectAt(i));
740 EXPECT_EQ(CPDF_Object::REFERENCE, arr1->GetObjectAt(i)->GetType()); 740 EXPECT_EQ(CPDF_Object::REFERENCE, arr1->GetObjectAt(i)->GetType());
741 EXPECT_EQ(indirect_objs[i], arr1->GetObjectAt(i)->GetDirect()); 741 EXPECT_EQ(indirect_objs[i], arr1->GetObjectAt(i)->GetDirect());
742 EXPECT_EQ(indirect_objs[i], arr1->GetDirectObjectAt(i)); 742 EXPECT_EQ(indirect_objs[i], arr1->GetDirectObjectAt(i));
743 } 743 }
744 } 744 }
OLDNEW
« no previous file with comments | « core/fpdfapi/fpdf_parser/cpdf_dictionary.cpp ('k') | core/fpdfapi/fpdf_parser/cpdf_parser.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698