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 #ifndef TESTING_EMBEDDER_TEST_SUPPORT_H_ | 5 #ifndef TESTING_EMBEDDER_TEST_SUPPORT_H_ |
6 #define TESTING_EMBEDDER_TEST_SUPPORT_H_ | 6 #define TESTING_EMBEDDER_TEST_SUPPORT_H_ |
7 | 7 |
8 #include <stdlib.h> | 8 #include <stdlib.h> |
9 #include <memory> | 9 #include <memory> |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 #include "public/fpdfview.h" | 12 #include "public/fpdfview.h" |
13 #include "public/fpdf_save.h" | 13 #include "public/fpdf_save.h" |
14 | 14 |
15 #ifdef PDF_ENABLE_V8 | 15 #ifdef PDF_ENABLE_V8 |
16 #include "v8/include/v8.h" | 16 #include "v8/include/v8.h" |
17 #endif // PDF_ENABLE_V8 | 17 #endif // PDF_ENABLE_V8 |
18 | 18 |
19 namespace pdfium { | 19 namespace pdfium { |
20 | 20 |
| 21 #define STR_TEST_CASE(input_literal, expected_literal) \ |
| 22 { \ |
| 23 (const unsigned char*) input_literal, sizeof(input_literal) - 1, \ |
| 24 (const unsigned char*)expected_literal, sizeof(expected_literal) - 1 \ |
| 25 } |
| 26 |
| 27 #define DECODE_TEST_CASE(input_literal, expected_literal, processed_size) \ |
| 28 { \ |
| 29 (const unsigned char*) input_literal, sizeof(input_literal) - 1, \ |
| 30 (const unsigned char*)expected_literal, sizeof(expected_literal) - 1, \ |
| 31 processed_size \ |
| 32 } |
| 33 |
| 34 struct StrFuncTestData { |
| 35 const unsigned char* input; |
| 36 unsigned int input_size; |
| 37 const unsigned char* expected; |
| 38 unsigned int expected_size; |
| 39 }; |
| 40 |
| 41 struct DecodeTestData { |
| 42 const unsigned char* input; |
| 43 unsigned int input_size; |
| 44 const unsigned char* expected; |
| 45 unsigned int expected_size; |
| 46 // The size of input string being processed. |
| 47 unsigned int processed_size; |
| 48 }; |
| 49 |
21 // Used with std::unique_ptr to free() objects that can't be deleted. | 50 // Used with std::unique_ptr to free() objects that can't be deleted. |
22 struct FreeDeleter { | 51 struct FreeDeleter { |
23 inline void operator()(void* ptr) const { free(ptr); } | 52 inline void operator()(void* ptr) const { free(ptr); } |
24 }; | 53 }; |
25 | 54 |
26 } // namespace pdfium | 55 } // namespace pdfium |
27 | 56 |
28 // Reads the entire contents of a file into a newly alloc'd buffer. | 57 // Reads the entire contents of a file into a newly alloc'd buffer. |
29 std::unique_ptr<char, pdfium::FreeDeleter> GetFileContents(const char* filename, | 58 std::unique_ptr<char, pdfium::FreeDeleter> GetFileContents(const char* filename, |
30 size_t* retlen); | 59 size_t* retlen); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 | 101 |
73 private: | 102 private: |
74 static int WriteBlockCallback(FPDF_FILEWRITE* pFileWrite, | 103 static int WriteBlockCallback(FPDF_FILEWRITE* pFileWrite, |
75 const void* data, | 104 const void* data, |
76 unsigned long size); | 105 unsigned long size); |
77 | 106 |
78 std::string m_String; | 107 std::string m_String; |
79 }; | 108 }; |
80 | 109 |
81 #endif // TESTING_EMBEDDER_TEST_SUPPORT_H_ | 110 #endif // TESTING_EMBEDDER_TEST_SUPPORT_H_ |
OLD | NEW |