| 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/fpdf_parser/cpdf_syntax_parser.h" | 8 #include "core/fpdfapi/fpdf_parser/cpdf_syntax_parser.h" |
| 9 #include "core/fpdfapi/fpdf_parser/include/cpdf_parser.h" | 9 #include "core/fpdfapi/fpdf_parser/include/cpdf_parser.h" |
| 10 #include "core/include/fxcrt/fx_ext.h" | 10 #include "core/include/fxcrt/fx_ext.h" |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 | 75 |
| 76 TEST(cpdf_parser, RebuildCrossRefCorrectly) { | 76 TEST(cpdf_parser, RebuildCrossRefCorrectly) { |
| 77 CPDF_TestParser parser; | 77 CPDF_TestParser parser; |
| 78 std::string test_file; | 78 std::string test_file; |
| 79 ASSERT_TRUE(PathService::GetTestFilePath("parser_rebuildxref_correct.pdf", | 79 ASSERT_TRUE(PathService::GetTestFilePath("parser_rebuildxref_correct.pdf", |
| 80 &test_file)); | 80 &test_file)); |
| 81 ASSERT_TRUE(parser.InitTestFromFile(test_file.c_str())) << test_file; | 81 ASSERT_TRUE(parser.InitTestFromFile(test_file.c_str())) << test_file; |
| 82 | 82 |
| 83 ASSERT_TRUE(parser.RebuildCrossRef()); | 83 ASSERT_TRUE(parser.RebuildCrossRef()); |
| 84 const FX_FILESIZE offsets[] = {0, 15, 61, 154, 296, 374, 450}; | 84 const FX_FILESIZE offsets[] = {0, 15, 61, 154, 296, 374, 450}; |
| 85 const FX_WORD versions[] = {0, 0, 2, 4, 6, 8, 0}; | 85 const uint16_t versions[] = {0, 0, 2, 4, 6, 8, 0}; |
| 86 for (size_t i = 0; i < FX_ArraySize(offsets); ++i) | 86 for (size_t i = 0; i < FX_ArraySize(offsets); ++i) |
| 87 EXPECT_EQ(offsets[i], parser.m_ObjectInfo[i].pos); | 87 EXPECT_EQ(offsets[i], parser.m_ObjectInfo[i].pos); |
| 88 for (size_t i = 0; i < FX_ArraySize(versions); ++i) | 88 for (size_t i = 0; i < FX_ArraySize(versions); ++i) |
| 89 EXPECT_EQ(versions[i], parser.m_ObjectInfo[i].gennum); | 89 EXPECT_EQ(versions[i], parser.m_ObjectInfo[i].gennum); |
| 90 } | 90 } |
| 91 | 91 |
| 92 TEST(cpdf_parser, RebuildCrossRefFailed) { | 92 TEST(cpdf_parser, RebuildCrossRefFailed) { |
| 93 CPDF_TestParser parser; | 93 CPDF_TestParser parser; |
| 94 std::string test_file; | 94 std::string test_file; |
| 95 ASSERT_TRUE(PathService::GetTestFilePath( | 95 ASSERT_TRUE(PathService::GetTestFilePath( |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 |