OLD | NEW |
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 "core/fpdfapi/parser/cpdf_parser.h" | 8 #include "core/fpdfapi/parser/cpdf_parser.h" |
9 #include "core/fpdfapi/parser/cpdf_syntax_parser.h" | 9 #include "core/fpdfapi/parser/cpdf_syntax_parser.h" |
10 #include "core/fxcrt/fx_ext.h" | 10 #include "core/fxcrt/fx_ext.h" |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 "0000000017 00000 n \n" | 108 "0000000017 00000 n \n" |
109 "0000000081 00000 n \n" | 109 "0000000081 00000 n \n" |
110 "0000000000 00007 f \n" | 110 "0000000000 00007 f \n" |
111 "0000000331 00000 n \n" | 111 "0000000331 00000 n \n" |
112 "0000000409 00000 n \n" | 112 "0000000409 00000 n \n" |
113 "trail"; // Needed to end cross ref table reading. | 113 "trail"; // Needed to end cross ref table reading. |
114 CPDF_TestParser parser; | 114 CPDF_TestParser parser; |
115 ASSERT_TRUE( | 115 ASSERT_TRUE( |
116 parser.InitTestFromBuffer(xref_table, FX_ArraySize(xref_table))); | 116 parser.InitTestFromBuffer(xref_table, FX_ArraySize(xref_table))); |
117 | 117 |
118 ASSERT_TRUE(parser.LoadCrossRefV4(0, 0, FALSE)); | 118 ASSERT_TRUE(parser.LoadCrossRefV4(0, 0, false)); |
119 const FX_FILESIZE offsets[] = {0, 17, 81, 0, 331, 409}; | 119 const FX_FILESIZE offsets[] = {0, 17, 81, 0, 331, 409}; |
120 const uint8_t types[] = {0, 1, 1, 0, 1, 1}; | 120 const uint8_t types[] = {0, 1, 1, 0, 1, 1}; |
121 for (size_t i = 0; i < FX_ArraySize(offsets); ++i) { | 121 for (size_t i = 0; i < FX_ArraySize(offsets); ++i) { |
122 EXPECT_EQ(offsets[i], parser.m_ObjectInfo[i].pos); | 122 EXPECT_EQ(offsets[i], parser.m_ObjectInfo[i].pos); |
123 EXPECT_EQ(types[i], parser.m_ObjectInfo[i].type); | 123 EXPECT_EQ(types[i], parser.m_ObjectInfo[i].type); |
124 } | 124 } |
125 } | 125 } |
126 { | 126 { |
127 const unsigned char xref_table[] = | 127 const unsigned char xref_table[] = |
128 "xref \n" | 128 "xref \n" |
129 "0 1 \n" | 129 "0 1 \n" |
130 "0000000000 65535 f \n" | 130 "0000000000 65535 f \n" |
131 "3 1 \n" | 131 "3 1 \n" |
132 "0000025325 00000 n \n" | 132 "0000025325 00000 n \n" |
133 "8 2 \n" | 133 "8 2 \n" |
134 "0000025518 00002 n \n" | 134 "0000025518 00002 n \n" |
135 "0000025635 00000 n \n" | 135 "0000025635 00000 n \n" |
136 "12 1 \n" | 136 "12 1 \n" |
137 "0000025777 00000 n \n" | 137 "0000025777 00000 n \n" |
138 "trail"; // Needed to end cross ref table reading. | 138 "trail"; // Needed to end cross ref table reading. |
139 CPDF_TestParser parser; | 139 CPDF_TestParser parser; |
140 ASSERT_TRUE( | 140 ASSERT_TRUE( |
141 parser.InitTestFromBuffer(xref_table, FX_ArraySize(xref_table))); | 141 parser.InitTestFromBuffer(xref_table, FX_ArraySize(xref_table))); |
142 | 142 |
143 ASSERT_TRUE(parser.LoadCrossRefV4(0, 0, FALSE)); | 143 ASSERT_TRUE(parser.LoadCrossRefV4(0, 0, false)); |
144 const FX_FILESIZE offsets[] = {0, 0, 0, 25325, 0, 0, 0, | 144 const FX_FILESIZE offsets[] = {0, 0, 0, 25325, 0, 0, 0, |
145 0, 25518, 25635, 0, 0, 25777}; | 145 0, 25518, 25635, 0, 0, 25777}; |
146 const uint8_t types[] = {0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1}; | 146 const uint8_t types[] = {0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1}; |
147 for (size_t i = 0; i < FX_ArraySize(offsets); ++i) { | 147 for (size_t i = 0; i < FX_ArraySize(offsets); ++i) { |
148 EXPECT_EQ(offsets[i], parser.m_ObjectInfo[i].pos); | 148 EXPECT_EQ(offsets[i], parser.m_ObjectInfo[i].pos); |
149 EXPECT_EQ(types[i], parser.m_ObjectInfo[i].type); | 149 EXPECT_EQ(types[i], parser.m_ObjectInfo[i].type); |
150 } | 150 } |
151 } | 151 } |
152 { | 152 { |
153 const unsigned char xref_table[] = | 153 const unsigned char xref_table[] = |
154 "xref \n" | 154 "xref \n" |
155 "0 1 \n" | 155 "0 1 \n" |
156 "0000000000 65535 f \n" | 156 "0000000000 65535 f \n" |
157 "3 1 \n" | 157 "3 1 \n" |
158 "0000025325 00000 n \n" | 158 "0000025325 00000 n \n" |
159 "8 2 \n" | 159 "8 2 \n" |
160 "0000000000 65535 f \n" | 160 "0000000000 65535 f \n" |
161 "0000025635 00000 n \n" | 161 "0000025635 00000 n \n" |
162 "12 1 \n" | 162 "12 1 \n" |
163 "0000025777 00000 n \n" | 163 "0000025777 00000 n \n" |
164 "trail"; // Needed to end cross ref table reading. | 164 "trail"; // Needed to end cross ref table reading. |
165 CPDF_TestParser parser; | 165 CPDF_TestParser parser; |
166 ASSERT_TRUE( | 166 ASSERT_TRUE( |
167 parser.InitTestFromBuffer(xref_table, FX_ArraySize(xref_table))); | 167 parser.InitTestFromBuffer(xref_table, FX_ArraySize(xref_table))); |
168 | 168 |
169 ASSERT_TRUE(parser.LoadCrossRefV4(0, 0, FALSE)); | 169 ASSERT_TRUE(parser.LoadCrossRefV4(0, 0, false)); |
170 const FX_FILESIZE offsets[] = {0, 0, 0, 25325, 0, 0, 0, | 170 const FX_FILESIZE offsets[] = {0, 0, 0, 25325, 0, 0, 0, |
171 0, 0, 25635, 0, 0, 25777}; | 171 0, 0, 25635, 0, 0, 25777}; |
172 const uint8_t types[] = {0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1}; | 172 const uint8_t types[] = {0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1}; |
173 for (size_t i = 0; i < FX_ArraySize(offsets); ++i) { | 173 for (size_t i = 0; i < FX_ArraySize(offsets); ++i) { |
174 EXPECT_EQ(offsets[i], parser.m_ObjectInfo[i].pos); | 174 EXPECT_EQ(offsets[i], parser.m_ObjectInfo[i].pos); |
175 EXPECT_EQ(types[i], parser.m_ObjectInfo[i].type); | 175 EXPECT_EQ(types[i], parser.m_ObjectInfo[i].type); |
176 } | 176 } |
177 } | 177 } |
178 { | 178 { |
179 const unsigned char xref_table[] = | 179 const unsigned char xref_table[] = |
180 "xref \n" | 180 "xref \n" |
181 "0 7 \n" | 181 "0 7 \n" |
182 "0000000002 65535 f \n" | 182 "0000000002 65535 f \n" |
183 "0000000023 00000 n \n" | 183 "0000000023 00000 n \n" |
184 "0000000003 65535 f \n" | 184 "0000000003 65535 f \n" |
185 "0000000004 65535 f \n" | 185 "0000000004 65535 f \n" |
186 "0000000000 65535 f \n" | 186 "0000000000 65535 f \n" |
187 "0000000045 00000 n \n" | 187 "0000000045 00000 n \n" |
188 "0000000179 00000 n \n" | 188 "0000000179 00000 n \n" |
189 "trail"; // Needed to end cross ref table reading. | 189 "trail"; // Needed to end cross ref table reading. |
190 CPDF_TestParser parser; | 190 CPDF_TestParser parser; |
191 ASSERT_TRUE( | 191 ASSERT_TRUE( |
192 parser.InitTestFromBuffer(xref_table, FX_ArraySize(xref_table))); | 192 parser.InitTestFromBuffer(xref_table, FX_ArraySize(xref_table))); |
193 | 193 |
194 ASSERT_TRUE(parser.LoadCrossRefV4(0, 0, FALSE)); | 194 ASSERT_TRUE(parser.LoadCrossRefV4(0, 0, false)); |
195 const FX_FILESIZE offsets[] = {0, 23, 0, 0, 0, 45, 179}; | 195 const FX_FILESIZE offsets[] = {0, 23, 0, 0, 0, 45, 179}; |
196 const uint8_t types[] = {0, 1, 0, 0, 0, 1, 1}; | 196 const uint8_t types[] = {0, 1, 0, 0, 0, 1, 1}; |
197 for (size_t i = 0; i < FX_ArraySize(offsets); ++i) { | 197 for (size_t i = 0; i < FX_ArraySize(offsets); ++i) { |
198 EXPECT_EQ(offsets[i], parser.m_ObjectInfo[i].pos); | 198 EXPECT_EQ(offsets[i], parser.m_ObjectInfo[i].pos); |
199 EXPECT_EQ(types[i], parser.m_ObjectInfo[i].type); | 199 EXPECT_EQ(types[i], parser.m_ObjectInfo[i].type); |
200 } | 200 } |
201 } | 201 } |
202 } | 202 } |
OLD | NEW |