| OLD | NEW |
| 1 // Copyright 2016 PDFium Authors. All rights reserved. | 1 // Copyright 2016 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/cpdf_simple_parser.h" | 5 #include "core/fpdfapi/fpdf_parser/include/cpdf_simple_parser.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "core/fpdfapi/fpdf_parser/fpdf_parser_utility.h" | 9 #include "core/fpdfapi/fpdf_parser/fpdf_parser_utility.h" |
| 10 #include "core/fxcrt/include/fx_basic.h" | 10 #include "core/fxcrt/include/fx_basic.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 STR_IN_OUT_CASE(" p t x c ", "p"), STR_IN_OUT_CASE(" pt\0xc ", "pt"), | 47 STR_IN_OUT_CASE(" p t x c ", "p"), STR_IN_OUT_CASE(" pt\0xc ", "pt"), |
| 48 STR_IN_OUT_CASE(" $^&&*\t\0sdff ", "$^&&*"), | 48 STR_IN_OUT_CASE(" $^&&*\t\0sdff ", "$^&&*"), |
| 49 STR_IN_OUT_CASE("\n\r+3.5656 -11.0", "+3.5656"), | 49 STR_IN_OUT_CASE("\n\r+3.5656 -11.0", "+3.5656"), |
| 50 }; | 50 }; |
| 51 for (size_t i = 0; i < FX_ArraySize(test_data); ++i) { | 51 for (size_t i = 0; i < FX_ArraySize(test_data); ++i) { |
| 52 const pdfium::StrFuncTestData& data = test_data[i]; | 52 const pdfium::StrFuncTestData& data = test_data[i]; |
| 53 CPDF_SimpleParser parser(data.input, data.input_size); | 53 CPDF_SimpleParser parser(data.input, data.input_size); |
| 54 CFX_ByteStringC word = parser.GetWord(); | 54 CFX_ByteStringC word = parser.GetWord(); |
| 55 EXPECT_EQ(std::string(reinterpret_cast<const char*>(data.expected), | 55 EXPECT_EQ(std::string(reinterpret_cast<const char*>(data.expected), |
| 56 data.expected_size), | 56 data.expected_size), |
| 57 std::string(word.GetCStr(), word.GetLength())) | 57 std::string(word.c_str(), word.GetLength())) |
| 58 << " for case " << i; | 58 << " for case " << i; |
| 59 } | 59 } |
| 60 } | 60 } |
| 61 | 61 |
| 62 TEST(SimpleParserTest, FindTagParamFromStart) { | 62 TEST(SimpleParserTest, FindTagParamFromStart) { |
| 63 struct FindTagTestStruct { | 63 struct FindTagTestStruct { |
| 64 const unsigned char* input; | 64 const unsigned char* input; |
| 65 unsigned int input_size; | 65 unsigned int input_size; |
| 66 const char* token; | 66 const char* token; |
| 67 int num_params; | 67 int num_params; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 87 }; | 87 }; |
| 88 for (size_t i = 0; i < FX_ArraySize(test_data); ++i) { | 88 for (size_t i = 0; i < FX_ArraySize(test_data); ++i) { |
| 89 const FindTagTestStruct& data = test_data[i]; | 89 const FindTagTestStruct& data = test_data[i]; |
| 90 CPDF_SimpleParser parser(data.input, data.input_size); | 90 CPDF_SimpleParser parser(data.input, data.input_size); |
| 91 EXPECT_EQ(data.result, | 91 EXPECT_EQ(data.result, |
| 92 parser.FindTagParamFromStart(data.token, data.num_params)) | 92 parser.FindTagParamFromStart(data.token, data.num_params)) |
| 93 << " for case " << i; | 93 << " for case " << i; |
| 94 EXPECT_EQ(data.result_pos, parser.GetCurPos()) << " for case " << i; | 94 EXPECT_EQ(data.result_pos, parser.GetCurPos()) << " for case " << i; |
| 95 } | 95 } |
| 96 } | 96 } |
| OLD | NEW |