diff options
author | Lei Zhang <thestig@chromium.org> | 2018-08-14 18:26:36 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-08-14 18:26:36 +0000 |
commit | 88798cff29934b58e0a8d81e94005472d612b964 (patch) | |
tree | 3b5a25faa2a627ac30de219b89c8152a9fff2f27 /core/fpdfapi/parser/cpdf_syntax_parser_unittest.cpp | |
parent | b9c3e2712f75363372622282023143b86b72f2df (diff) | |
download | pdfium-88798cff29934b58e0a8d81e94005472d612b964.tar.xz |
Remove CFX_BufferSeekableReadStream.
Replace it with CFX_ReadOnlyMemoryStream, which does the same thing.
Take some checks from CFX_BufferSeekableReadStream and add them
CFX_ReadOnlyMemoryStream.
Change-Id: I25554c3aec3ec96967f8df16ca68a64dba121b6f
Reviewed-on: https://pdfium-review.googlesource.com/40070
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'core/fpdfapi/parser/cpdf_syntax_parser_unittest.cpp')
-rw-r--r-- | core/fpdfapi/parser/cpdf_syntax_parser_unittest.cpp | 33 |
1 files changed, 16 insertions, 17 deletions
diff --git a/core/fpdfapi/parser/cpdf_syntax_parser_unittest.cpp b/core/fpdfapi/parser/cpdf_syntax_parser_unittest.cpp index 498eddf12b..5b06d33d4b 100644 --- a/core/fpdfapi/parser/cpdf_syntax_parser_unittest.cpp +++ b/core/fpdfapi/parser/cpdf_syntax_parser_unittest.cpp @@ -8,8 +8,8 @@ #include "core/fpdfapi/parser/cpdf_object.h" #include "core/fpdfapi/parser/cpdf_parser.h" #include "core/fpdfapi/parser/cpdf_syntax_parser.h" +#include "core/fxcrt/cfx_readonlymemorystream.h" #include "core/fxcrt/fx_extension.h" -#include "testing/fx_string_testhelpers.h" #include "testing/gtest/include/gtest/gtest.h" #include "testing/utils/path_service.h" @@ -17,7 +17,7 @@ TEST(cpdf_syntax_parser, ReadHexString) { { // Empty string. static const uint8_t data[] = ""; - CPDF_SyntaxParser parser(pdfium::MakeRetain<CFX_BufferSeekableReadStream>( + CPDF_SyntaxParser parser(pdfium::MakeRetain<CFX_ReadOnlyMemoryStream>( pdfium::make_span(data, 0))); EXPECT_EQ("", parser.ReadHexString()); EXPECT_EQ(0, parser.GetPos()); @@ -26,7 +26,7 @@ TEST(cpdf_syntax_parser, ReadHexString) { { // Blank string. static const uint8_t data[] = " "; - CPDF_SyntaxParser parser(pdfium::MakeRetain<CFX_BufferSeekableReadStream>( + CPDF_SyntaxParser parser(pdfium::MakeRetain<CFX_ReadOnlyMemoryStream>( pdfium::make_span(data, 2))); EXPECT_EQ("", parser.ReadHexString()); EXPECT_EQ(2, parser.GetPos()); @@ -35,7 +35,7 @@ TEST(cpdf_syntax_parser, ReadHexString) { { // Skips unknown characters. static const uint8_t data[] = "z12b"; - CPDF_SyntaxParser parser(pdfium::MakeRetain<CFX_BufferSeekableReadStream>( + CPDF_SyntaxParser parser(pdfium::MakeRetain<CFX_ReadOnlyMemoryStream>( pdfium::make_span(data, 4))); EXPECT_EQ("\x12\xb0", parser.ReadHexString()); EXPECT_EQ(4, parser.GetPos()); @@ -44,7 +44,7 @@ TEST(cpdf_syntax_parser, ReadHexString) { { // Skips unknown characters. static const uint8_t data[] = "*<&*#$^&@1"; - CPDF_SyntaxParser parser(pdfium::MakeRetain<CFX_BufferSeekableReadStream>( + CPDF_SyntaxParser parser(pdfium::MakeRetain<CFX_ReadOnlyMemoryStream>( pdfium::make_span(data, 10))); EXPECT_EQ("\x10", parser.ReadHexString()); EXPECT_EQ(10, parser.GetPos()); @@ -53,7 +53,7 @@ TEST(cpdf_syntax_parser, ReadHexString) { { // Skips unknown characters. static const uint8_t data[] = "\x80zab"; - CPDF_SyntaxParser parser(pdfium::MakeRetain<CFX_BufferSeekableReadStream>( + CPDF_SyntaxParser parser(pdfium::MakeRetain<CFX_ReadOnlyMemoryStream>( pdfium::make_span(data, 4))); EXPECT_EQ("\xab", parser.ReadHexString()); EXPECT_EQ(4, parser.GetPos()); @@ -62,7 +62,7 @@ TEST(cpdf_syntax_parser, ReadHexString) { { // Skips unknown characters. static const uint8_t data[] = "\xffzab"; - CPDF_SyntaxParser parser(pdfium::MakeRetain<CFX_BufferSeekableReadStream>( + CPDF_SyntaxParser parser(pdfium::MakeRetain<CFX_ReadOnlyMemoryStream>( pdfium::make_span(data, 4))); EXPECT_EQ("\xab", parser.ReadHexString()); EXPECT_EQ(4, parser.GetPos()); @@ -71,7 +71,7 @@ TEST(cpdf_syntax_parser, ReadHexString) { { // Regular conversion. static const uint8_t data[] = "1A2b>abcd"; - CPDF_SyntaxParser parser(pdfium::MakeRetain<CFX_BufferSeekableReadStream>( + CPDF_SyntaxParser parser(pdfium::MakeRetain<CFX_ReadOnlyMemoryStream>( pdfium::make_span(data, 9))); EXPECT_EQ("\x1a\x2b", parser.ReadHexString()); EXPECT_EQ(5, parser.GetPos()); @@ -80,7 +80,7 @@ TEST(cpdf_syntax_parser, ReadHexString) { { // Position out of bounds. static const uint8_t data[] = "12ab>"; - CPDF_SyntaxParser parser(pdfium::MakeRetain<CFX_BufferSeekableReadStream>( + CPDF_SyntaxParser parser(pdfium::MakeRetain<CFX_ReadOnlyMemoryStream>( pdfium::make_span(data, 5))); parser.SetPos(5); EXPECT_EQ("", parser.ReadHexString()); @@ -102,7 +102,7 @@ TEST(cpdf_syntax_parser, ReadHexString) { { // Missing ending >. static const uint8_t data[] = "1A2b"; - CPDF_SyntaxParser parser(pdfium::MakeRetain<CFX_BufferSeekableReadStream>( + CPDF_SyntaxParser parser(pdfium::MakeRetain<CFX_ReadOnlyMemoryStream>( pdfium::make_span(data, 4))); EXPECT_EQ("\x1a\x2b", parser.ReadHexString()); EXPECT_EQ(4, parser.GetPos()); @@ -111,7 +111,7 @@ TEST(cpdf_syntax_parser, ReadHexString) { { // Missing ending >. static const uint8_t data[] = "12abz"; - CPDF_SyntaxParser parser(pdfium::MakeRetain<CFX_BufferSeekableReadStream>( + CPDF_SyntaxParser parser(pdfium::MakeRetain<CFX_ReadOnlyMemoryStream>( pdfium::make_span(data, 5))); EXPECT_EQ("\x12\xab", parser.ReadHexString()); EXPECT_EQ(5, parser.GetPos()); @@ -120,7 +120,7 @@ TEST(cpdf_syntax_parser, ReadHexString) { { // Uneven number of bytes. static const uint8_t data[] = "1A2>asdf"; - CPDF_SyntaxParser parser(pdfium::MakeRetain<CFX_BufferSeekableReadStream>( + CPDF_SyntaxParser parser(pdfium::MakeRetain<CFX_ReadOnlyMemoryStream>( pdfium::make_span(data, 8))); EXPECT_EQ("\x1a\x20", parser.ReadHexString()); EXPECT_EQ(4, parser.GetPos()); @@ -129,7 +129,7 @@ TEST(cpdf_syntax_parser, ReadHexString) { { // Uneven number of bytes. static const uint8_t data[] = "1A2zasdf"; - CPDF_SyntaxParser parser(pdfium::MakeRetain<CFX_BufferSeekableReadStream>( + CPDF_SyntaxParser parser(pdfium::MakeRetain<CFX_ReadOnlyMemoryStream>( pdfium::make_span(data, 8))); EXPECT_EQ("\x1a\x2a\xdf", parser.ReadHexString()); EXPECT_EQ(8, parser.GetPos()); @@ -138,7 +138,7 @@ TEST(cpdf_syntax_parser, ReadHexString) { { // Just ending character. static const uint8_t data[] = ">"; - CPDF_SyntaxParser parser(pdfium::MakeRetain<CFX_BufferSeekableReadStream>( + CPDF_SyntaxParser parser(pdfium::MakeRetain<CFX_ReadOnlyMemoryStream>( pdfium::make_span(data, 1))); EXPECT_EQ("", parser.ReadHexString()); EXPECT_EQ(1, parser.GetPos()); @@ -148,7 +148,7 @@ TEST(cpdf_syntax_parser, ReadHexString) { TEST(cpdf_syntax_parser, GetInvalidReference) { // Data with a reference with number CPDF_Object::kInvalidObjNum static const uint8_t data[] = "4294967295 0 R"; - CPDF_SyntaxParser parser(pdfium::MakeRetain<CFX_BufferSeekableReadStream>( + CPDF_SyntaxParser parser(pdfium::MakeRetain<CFX_ReadOnlyMemoryStream>( pdfium::make_span(data, 14))); std::unique_ptr<CPDF_Object> ref = parser.GetObjectBody(nullptr); EXPECT_FALSE(ref); @@ -156,8 +156,7 @@ TEST(cpdf_syntax_parser, GetInvalidReference) { TEST(cpdf_syntax_parser, PeekNextWord) { static const uint8_t data[] = " WORD "; - CPDF_SyntaxParser parser( - pdfium::MakeRetain<CFX_BufferSeekableReadStream>(data)); + CPDF_SyntaxParser parser(pdfium::MakeRetain<CFX_ReadOnlyMemoryStream>(data)); EXPECT_EQ("WORD", parser.PeekNextWord(nullptr)); EXPECT_EQ("WORD", parser.GetNextWord(nullptr)); } |