From 6058efdbdc186e120e7e2121c290ac4d820ffbf8 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Fri, 6 Apr 2018 23:48:24 +0000 Subject: Add span.h from chromium base. Allows indexing with better bounds-checking to occur. Some small modifications are required to deal with PDFium being intentionally held at C++11 compliance, not C++14. Use in one place as check on correctness. Change-Id: Id2875cf0a93980112bc536a93c4f9ec5306c0dac Reviewed-on: https://pdfium-review.googlesource.com/29671 Commit-Queue: Tom Sepez Reviewed-by: Chris Palmer Reviewed-by: dsinclair --- core/fpdfapi/page/cpdf_streamparser_unittest.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'core/fpdfapi/page/cpdf_streamparser_unittest.cpp') diff --git a/core/fpdfapi/page/cpdf_streamparser_unittest.cpp b/core/fpdfapi/page/cpdf_streamparser_unittest.cpp index 40a41befe1..d83fedcb7d 100644 --- a/core/fpdfapi/page/cpdf_streamparser_unittest.cpp +++ b/core/fpdfapi/page/cpdf_streamparser_unittest.cpp @@ -4,12 +4,13 @@ #include "core/fpdfapi/page/cpdf_streamparser.h" #include "testing/gtest/include/gtest/gtest.h" +#include "third_party/base/span.h" TEST(cpdf_streamparser, ReadHexString) { { // Position out of bounds. uint8_t data[] = "12ab>"; - CPDF_StreamParser parser(data, 5); + CPDF_StreamParser parser(data); parser.SetPos(6); EXPECT_EQ("", parser.ReadHexString()); } @@ -17,7 +18,7 @@ TEST(cpdf_streamparser, ReadHexString) { { // Regular conversion. uint8_t data[] = "1A2b>abcd"; - CPDF_StreamParser parser(data, 5); + CPDF_StreamParser parser(data); EXPECT_EQ("\x1a\x2b", parser.ReadHexString()); EXPECT_EQ(5u, parser.GetPos()); } @@ -25,7 +26,7 @@ TEST(cpdf_streamparser, ReadHexString) { { // Missing ending > uint8_t data[] = "1A2b"; - CPDF_StreamParser parser(data, 5); + CPDF_StreamParser parser(data); EXPECT_EQ("\x1a\x2b", parser.ReadHexString()); EXPECT_EQ(5u, parser.GetPos()); } @@ -33,14 +34,14 @@ TEST(cpdf_streamparser, ReadHexString) { { // Uneven number of bytes. uint8_t data[] = "1A2>asdf"; - CPDF_StreamParser parser(data, 5); + CPDF_StreamParser parser(data); EXPECT_EQ("\x1a\x20", parser.ReadHexString()); EXPECT_EQ(4u, parser.GetPos()); } { uint8_t data[] = ">"; - CPDF_StreamParser parser(data, 5); + CPDF_StreamParser parser(data); EXPECT_EQ("", parser.ReadHexString()); EXPECT_EQ(1u, parser.GetPos()); } -- cgit v1.2.3