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 "core/fpdfapi/fpdf_parser/include/fpdf_parser_decode.h" | 5 #include "core/fpdfapi/fpdf_parser/include/fpdf_parser_decode.h" |
6 | 6 |
7 #include <cstring> | 7 #include <cstring> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "core/fxcrt/include/fx_basic.h" | 10 #include "core/fxcrt/include/fx_basic.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 "\x78\x9c\x33\x54\x30\x00\x42\x5d\x43\x05\x23\x4b\x05\x73\x33\x63" | 31 "\x78\x9c\x33\x54\x30\x00\x42\x5d\x43\x05\x23\x4b\x05\x73\x33\x63" |
32 "\x85\xe4\x5c\x2e\x90\x80\xa9\xa9\xa9\x82\xb9\xb1\xa9\x42\x51\x2a" | 32 "\x85\xe4\x5c\x2e\x90\x80\xa9\xa9\xa9\x82\xb9\xb1\xa9\x42\x51\x2a" |
33 "\x57\xb8\x42\x1e\x57\x21\x92\xa0\x89\x9e\xb1\xa5\x09\x92\x84\x9e" | 33 "\x57\xb8\x42\x1e\x57\x21\x92\xa0\x89\x9e\xb1\xa5\x09\x92\x84\x9e" |
34 "\x85\x81\x81\x25\xd8\x14\x24\x26\xd0\x18\x43\x05\x10\x0c\x72\x57" | 34 "\x85\x81\x81\x25\xd8\x14\x24\x26\xd0\x18\x43\x05\x10\x0c\x72\x57" |
35 "\x80\x30\x8a\xd2\xb9\xf4\xdd\x0d\x14\xd2\x8b\xc1\x46\x99\x59\x1a" | 35 "\x80\x30\x8a\xd2\xb9\xf4\xdd\x0d\x14\xd2\x8b\xc1\x46\x99\x59\x1a" |
36 "\x2b\x58\x1a\x9a\x83\x8c\x49\xe3\x0a\x04\x42\x00\x37\x4c\x1b\x42"), | 36 "\x2b\x58\x1a\x9a\x83\x8c\x49\xe3\x0a\x04\x42\x00\x37\x4c\x1b\x42"), |
37 }; | 37 }; |
38 | 38 |
39 for (size_t i = 0; i < FX_ArraySize(flate_encode_cases); ++i) { | 39 for (size_t i = 0; i < FX_ArraySize(flate_encode_cases); ++i) { |
40 const pdfium::StrFuncTestData& data = flate_encode_cases[i]; | 40 const pdfium::StrFuncTestData& data = flate_encode_cases[i]; |
41 unsigned char* result; | 41 unsigned char* buf = nullptr; |
42 unsigned int result_size; | 42 unsigned int buf_size; |
43 FlateEncode(data.input, data.input_size, result, result_size); | 43 EXPECT_TRUE(FlateEncode(data.input, data.input_size, &buf, &buf_size)); |
44 ASSERT_TRUE(result); | 44 ASSERT_TRUE(buf); |
45 EXPECT_EQ(std::string((const char*)data.expected, data.expected_size), | 45 EXPECT_EQ(std::string((const char*)data.expected, data.expected_size), |
46 std::string((const char*)result, result_size)) | 46 std::string((const char*)buf, buf_size)) |
47 << " for case " << i; | 47 << " for case " << i; |
48 FX_Free(result); | 48 FX_Free(buf); |
49 } | 49 } |
50 } | 50 } |
51 | 51 |
52 TEST_F(FPDFParserDecodeEmbeddertest, FlateDecode) { | 52 TEST_F(FPDFParserDecodeEmbeddertest, FlateDecode) { |
53 pdfium::DecodeTestData flate_decode_cases[] = { | 53 pdfium::DecodeTestData flate_decode_cases[] = { |
54 STR_IN_OUT_CASE("", "", 0), | 54 STR_IN_OUT_CASE("", "", 0), |
55 STR_IN_OUT_CASE("preposterous nonsense", "", 2), | 55 STR_IN_OUT_CASE("preposterous nonsense", "", 2), |
56 STR_IN_OUT_CASE("\x78\x9c\x03\x00\x00\x00\x00\x01", "", 8), | 56 STR_IN_OUT_CASE("\x78\x9c\x03\x00\x00\x00\x00\x01", "", 8), |
57 STR_IN_OUT_CASE("\x78\x9c\x53\x00\x00\x00\x21\x00\x21", " ", 9), | 57 STR_IN_OUT_CASE("\x78\x9c\x53\x00\x00\x00\x21\x00\x21", " ", 9), |
58 STR_IN_OUT_CASE("\x78\x9c\x33\x34\x32\x06\x00\01\x2d\x00\x97", "123", 11), | 58 STR_IN_OUT_CASE("\x78\x9c\x33\x34\x32\x06\x00\01\x2d\x00\x97", "123", 11), |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 | 108 |
109 TEST_F(FPDFParserDecodeEmbeddertest, Bug_455199) { | 109 TEST_F(FPDFParserDecodeEmbeddertest, Bug_455199) { |
110 // Tests object numbers with a value > 01000000. | 110 // Tests object numbers with a value > 01000000. |
111 // Should open successfully. | 111 // Should open successfully. |
112 EXPECT_TRUE(OpenDocument("bug_455199.pdf")); | 112 EXPECT_TRUE(OpenDocument("bug_455199.pdf")); |
113 FPDF_PAGE page = LoadPage(0); | 113 FPDF_PAGE page = LoadPage(0); |
114 FPDF_BITMAP bitmap = RenderPage(page); | 114 FPDF_BITMAP bitmap = RenderPage(page); |
115 FPDFBitmap_Destroy(bitmap); | 115 FPDFBitmap_Destroy(bitmap); |
116 UnloadPage(page); | 116 UnloadPage(page); |
117 } | 117 } |
OLD | NEW |