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

Side by Side Diff: fpdfsdk/fpdfview_embeddertest.cpp

Issue 1841643002: Code change to avoid signed/unsigned mismatch warnings (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: rebase 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 | « fpdfsdk/fpdfview.cpp ('k') | fpdfsdk/javascript/Field.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 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 <limits> 5 #include <limits>
6 #include <string> 6 #include <string>
7 7
8 #include "fpdfsdk/fpdfview_c_api_test.h" 8 #include "fpdfsdk/fpdfview_c_api_test.h"
9 #include "public/fpdfview.h" 9 #include "public/fpdfview.h"
10 #include "testing/embedder_test.h" 10 #include "testing/embedder_test.h"
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 EXPECT_EQ(10u, buffer_size); 81 EXPECT_EQ(10u, buffer_size);
82 EXPECT_EQ(std::string("N\0e\0x\0t\0\0\0", 10), 82 EXPECT_EQ(std::string("N\0e\0x\0t\0\0\0", 10),
83 std::string(fixed_buffer, buffer_size)); 83 std::string(fixed_buffer, buffer_size));
84 84
85 // Try to retrieve third item with ample buffer. Item is taken 85 // Try to retrieve third item with ample buffer. Item is taken
86 // from Dests NameTree but has a bad sub-dictionary in named_dests.pdf. 86 // from Dests NameTree but has a bad sub-dictionary in named_dests.pdf.
87 // in named_dests.pdf). 87 // in named_dests.pdf).
88 buffer_size = sizeof(fixed_buffer); 88 buffer_size = sizeof(fixed_buffer);
89 dest = FPDF_GetNamedDest(document(), 2, fixed_buffer, &buffer_size); 89 dest = FPDF_GetNamedDest(document(), 2, fixed_buffer, &buffer_size);
90 EXPECT_EQ(nullptr, dest); 90 EXPECT_EQ(nullptr, dest);
91 EXPECT_EQ(sizeof(fixed_buffer), buffer_size); // unmodified. 91 EXPECT_EQ(sizeof(fixed_buffer),
92 static_cast<size_t>(buffer_size)); // unmodified.
92 93
93 // Try to retrieve the forth item with ample buffer. Item is taken 94 // Try to retrieve the forth item with ample buffer. Item is taken
94 // from Dests NameTree but has a vale of the wrong type in named_dests.pdf. 95 // from Dests NameTree but has a vale of the wrong type in named_dests.pdf.
95 buffer_size = sizeof(fixed_buffer); 96 buffer_size = sizeof(fixed_buffer);
96 dest = FPDF_GetNamedDest(document(), 3, fixed_buffer, &buffer_size); 97 dest = FPDF_GetNamedDest(document(), 3, fixed_buffer, &buffer_size);
97 EXPECT_EQ(nullptr, dest); 98 EXPECT_EQ(nullptr, dest);
98 EXPECT_EQ(sizeof(fixed_buffer), buffer_size); // unmodified. 99 EXPECT_EQ(sizeof(fixed_buffer),
100 static_cast<size_t>(buffer_size)); // unmodified.
99 101
100 // Try to retrieve fifth item with ample buffer. Item taken from the 102 // Try to retrieve fifth item with ample buffer. Item taken from the
101 // old-style Dests dictionary object in named_dests.pdf. 103 // old-style Dests dictionary object in named_dests.pdf.
102 buffer_size = sizeof(fixed_buffer); 104 buffer_size = sizeof(fixed_buffer);
103 dest = FPDF_GetNamedDest(document(), 4, fixed_buffer, &buffer_size); 105 dest = FPDF_GetNamedDest(document(), 4, fixed_buffer, &buffer_size);
104 EXPECT_NE(nullptr, dest); 106 EXPECT_NE(nullptr, dest);
105 EXPECT_EQ(30u, buffer_size); 107 EXPECT_EQ(30u, buffer_size);
106 EXPECT_EQ(std::string("F\0i\0r\0s\0t\0A\0l\0t\0e\0r\0n\0a\0t\0e\0\0\0", 30), 108 EXPECT_EQ(std::string("F\0i\0r\0s\0t\0A\0l\0t\0e\0r\0n\0a\0t\0e\0\0\0", 30),
107 std::string(fixed_buffer, buffer_size)); 109 std::string(fixed_buffer, buffer_size));
108 110
109 // Try to retrieve sixth item with ample buffer. Item istaken from the 111 // Try to retrieve sixth item with ample buffer. Item istaken from the
110 // old-style Dests dictionary object but has a sub-dictionary in 112 // old-style Dests dictionary object but has a sub-dictionary in
111 // named_dests.pdf. 113 // named_dests.pdf.
112 buffer_size = sizeof(fixed_buffer); 114 buffer_size = sizeof(fixed_buffer);
113 dest = FPDF_GetNamedDest(document(), 5, fixed_buffer, &buffer_size); 115 dest = FPDF_GetNamedDest(document(), 5, fixed_buffer, &buffer_size);
114 EXPECT_NE(nullptr, dest); 116 EXPECT_NE(nullptr, dest);
115 EXPECT_EQ(28u, buffer_size); 117 EXPECT_EQ(28u, buffer_size);
116 EXPECT_EQ(std::string("L\0a\0s\0t\0A\0l\0t\0e\0r\0n\0a\0t\0e\0\0\0", 28), 118 EXPECT_EQ(std::string("L\0a\0s\0t\0A\0l\0t\0e\0r\0n\0a\0t\0e\0\0\0", 28),
117 std::string(fixed_buffer, buffer_size)); 119 std::string(fixed_buffer, buffer_size));
118 120
119 // Try to retrieve non-existent item with ample buffer. 121 // Try to retrieve non-existent item with ample buffer.
120 buffer_size = sizeof(fixed_buffer); 122 buffer_size = sizeof(fixed_buffer);
121 dest = FPDF_GetNamedDest(document(), 6, fixed_buffer, &buffer_size); 123 dest = FPDF_GetNamedDest(document(), 6, fixed_buffer, &buffer_size);
122 EXPECT_EQ(nullptr, dest); 124 EXPECT_EQ(nullptr, dest);
123 EXPECT_EQ(sizeof(fixed_buffer), buffer_size); // unmodified. 125 EXPECT_EQ(sizeof(fixed_buffer),
126 static_cast<size_t>(buffer_size)); // unmodified.
124 127
125 // Try to underflow/overflow the integer index. 128 // Try to underflow/overflow the integer index.
126 buffer_size = sizeof(fixed_buffer); 129 buffer_size = sizeof(fixed_buffer);
127 dest = FPDF_GetNamedDest(document(), std::numeric_limits<int>::max(), 130 dest = FPDF_GetNamedDest(document(), std::numeric_limits<int>::max(),
128 fixed_buffer, &buffer_size); 131 fixed_buffer, &buffer_size);
129 EXPECT_EQ(nullptr, dest); 132 EXPECT_EQ(nullptr, dest);
130 EXPECT_EQ(sizeof(fixed_buffer), buffer_size); // unmodified. 133 EXPECT_EQ(sizeof(fixed_buffer),
134 static_cast<size_t>(buffer_size)); // unmodified.
131 135
132 buffer_size = sizeof(fixed_buffer); 136 buffer_size = sizeof(fixed_buffer);
133 dest = FPDF_GetNamedDest(document(), std::numeric_limits<int>::min(), 137 dest = FPDF_GetNamedDest(document(), std::numeric_limits<int>::min(),
134 fixed_buffer, &buffer_size); 138 fixed_buffer, &buffer_size);
135 EXPECT_EQ(nullptr, dest); 139 EXPECT_EQ(nullptr, dest);
136 EXPECT_EQ(sizeof(fixed_buffer), buffer_size); // unmodified. 140 EXPECT_EQ(sizeof(fixed_buffer),
141 static_cast<size_t>(buffer_size)); // unmodified.
137 142
138 buffer_size = sizeof(fixed_buffer); 143 buffer_size = sizeof(fixed_buffer);
139 dest = FPDF_GetNamedDest(document(), -1, fixed_buffer, &buffer_size); 144 dest = FPDF_GetNamedDest(document(), -1, fixed_buffer, &buffer_size);
140 EXPECT_EQ(nullptr, dest); 145 EXPECT_EQ(nullptr, dest);
141 EXPECT_EQ(sizeof(fixed_buffer), buffer_size); // unmodified. 146 EXPECT_EQ(sizeof(fixed_buffer),
147 static_cast<size_t>(buffer_size)); // unmodified.
142 } 148 }
143 149
144 TEST_F(FPDFViewEmbeddertest, NamedDestsByName) { 150 TEST_F(FPDFViewEmbeddertest, NamedDestsByName) {
145 EXPECT_TRUE(OpenDocument("named_dests.pdf")); 151 EXPECT_TRUE(OpenDocument("named_dests.pdf"));
146 152
147 // Null pointer returns NULL. 153 // Null pointer returns NULL.
148 FPDF_DEST dest = FPDF_GetNamedDestByName(document(), nullptr); 154 FPDF_DEST dest = FPDF_GetNamedDestByName(document(), nullptr);
149 EXPECT_EQ(nullptr, dest); 155 EXPECT_EQ(nullptr, dest);
150 156
151 // Empty string returns NULL. 157 // Empty string returns NULL.
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 243
238 // The test should pass when there is no infinite recursion in 244 // The test should pass when there is no infinite recursion in
239 // CPDF_SyntaxParser::GetString(). 245 // CPDF_SyntaxParser::GetString().
240 TEST_F(FPDFViewEmbeddertest, Hang_355) { 246 TEST_F(FPDFViewEmbeddertest, Hang_355) {
241 EXPECT_FALSE(OpenDocument("bug_355.pdf")); 247 EXPECT_FALSE(OpenDocument("bug_355.pdf"));
242 } 248 }
243 // The test should pass even when the file has circular references to pages. 249 // The test should pass even when the file has circular references to pages.
244 TEST_F(FPDFViewEmbeddertest, Hang_360) { 250 TEST_F(FPDFViewEmbeddertest, Hang_360) {
245 EXPECT_FALSE(OpenDocument("bug_360.pdf")); 251 EXPECT_FALSE(OpenDocument("bug_360.pdf"));
246 } 252 }
OLDNEW
« no previous file with comments | « fpdfsdk/fpdfview.cpp ('k') | fpdfsdk/javascript/Field.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698