Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1838)

Unified Diff: core/src/fpdfapi/fpdf_page/fpdf_page_parser_old_unittest.cpp

Issue 1408213008: Add test for CPDF_StreamParser::ReadHexString. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « BUILD.gn ('k') | core/src/fpdfapi/fpdf_page/pageint.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/src/fpdfapi/fpdf_page/fpdf_page_parser_old_unittest.cpp
diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page_parser_old_unittest.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page_parser_old_unittest.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..3fc012f29c202ac774bef9777ad4f562908c4064
--- /dev/null
+++ b/core/src/fpdfapi/fpdf_page/fpdf_page_parser_old_unittest.cpp
@@ -0,0 +1,48 @@
+// Copyright 2015 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "testing/gtest/include/gtest/gtest.h"
+
+#include "pageint.h"
+
+TEST(fpdf_page_parser_old, ReadHexString) {
+ {
+ // Position out of bounds.
+ uint8_t data[] = "12ab>";
+ CPDF_StreamParser parser(data, 5);
+ parser.SetPos(6);
+ EXPECT_EQ("", parser.ReadHexString());
+ }
+
+ {
+ // Regular conversion.
+ uint8_t data[] = "1A2b>abcd";
+ CPDF_StreamParser parser(data, 5);
+ EXPECT_EQ("\x1a\x2b", parser.ReadHexString());
+ EXPECT_EQ(5, parser.GetPos());
+ }
+
+ {
+ // Missing ending >
+ uint8_t data[] = "1A2b";
+ CPDF_StreamParser parser(data, 5);
+ EXPECT_EQ("\x1a\x2b", parser.ReadHexString());
+ EXPECT_EQ(5, parser.GetPos());
+ }
+
+ {
+ // Uneven number of bytes.
+ uint8_t data[] = "1A2>asdf";
+ CPDF_StreamParser parser(data, 5);
+ EXPECT_EQ("\x1a\x20", parser.ReadHexString());
+ EXPECT_EQ(4, parser.GetPos());
+ }
+
+ {
+ uint8_t data[] = ">";
+ CPDF_StreamParser parser(data, 5);
+ EXPECT_EQ("", parser.ReadHexString());
+ EXPECT_EQ(1, parser.GetPos());
+ }
+}
« no previous file with comments | « BUILD.gn ('k') | core/src/fpdfapi/fpdf_page/pageint.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698