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

Unified Diff: core/fpdfapi/parser/cpdf_syntax_parser_unittest.cpp

Issue 2451493002: Refcount all the IFX_ stream classes all the time. (Closed)
Patch Set: Clean up cast expression Created 4 years 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 | « core/fpdfapi/parser/cpdf_syntax_parser.cpp ('k') | core/fpdfapi/parser/fpdf_parser_utility.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/fpdfapi/parser/cpdf_syntax_parser_unittest.cpp
diff --git a/core/fpdfapi/parser/cpdf_syntax_parser_unittest.cpp b/core/fpdfapi/parser/cpdf_syntax_parser_unittest.cpp
index f94b431c82f721c4ac349c392bac6bd22b612a24..faaa83dd1967b3c511158fdf1a7d97ded24b31fb 100644
--- a/core/fpdfapi/parser/cpdf_syntax_parser_unittest.cpp
+++ b/core/fpdfapi/parser/cpdf_syntax_parser_unittest.cpp
@@ -16,10 +16,8 @@ TEST(cpdf_syntax_parser, ReadHexString) {
{
// Empty string.
uint8_t data[] = "";
- ScopedFileStream stream(IFX_MemoryStream::Create(data, 0, false));
-
CPDF_SyntaxParser parser;
- parser.InitParser(stream.get(), 0);
+ parser.InitParser(IFX_MemoryStream::Create(data, 0, false), 0);
EXPECT_EQ("", parser.ReadHexString());
EXPECT_EQ(0, parser.SavePos());
}
@@ -27,10 +25,8 @@ TEST(cpdf_syntax_parser, ReadHexString) {
{
// Blank string.
uint8_t data[] = " ";
- ScopedFileStream stream(IFX_MemoryStream::Create(data, 2, false));
-
CPDF_SyntaxParser parser;
- parser.InitParser(stream.get(), 0);
+ parser.InitParser(IFX_MemoryStream::Create(data, 2, false), 0);
EXPECT_EQ("", parser.ReadHexString());
EXPECT_EQ(2, parser.SavePos());
}
@@ -38,10 +34,8 @@ TEST(cpdf_syntax_parser, ReadHexString) {
{
// Skips unknown characters.
uint8_t data[] = "z12b";
- ScopedFileStream stream(IFX_MemoryStream::Create(data, 4, false));
-
CPDF_SyntaxParser parser;
- parser.InitParser(stream.get(), 0);
+ parser.InitParser(IFX_MemoryStream::Create(data, 4, false), 0);
EXPECT_EQ("\x12\xb0", parser.ReadHexString());
EXPECT_EQ(4, parser.SavePos());
}
@@ -49,10 +43,8 @@ TEST(cpdf_syntax_parser, ReadHexString) {
{
// Skips unknown characters.
uint8_t data[] = "*<&*#$^&@1";
- ScopedFileStream stream(IFX_MemoryStream::Create(data, 10, false));
-
CPDF_SyntaxParser parser;
- parser.InitParser(stream.get(), 0);
+ parser.InitParser(IFX_MemoryStream::Create(data, 10, false), 0);
EXPECT_EQ("\x10", parser.ReadHexString());
EXPECT_EQ(10, parser.SavePos());
}
@@ -60,10 +52,8 @@ TEST(cpdf_syntax_parser, ReadHexString) {
{
// Skips unknown characters.
uint8_t data[] = "\x80zab";
- ScopedFileStream stream(IFX_MemoryStream::Create(data, 4, false));
-
CPDF_SyntaxParser parser;
- parser.InitParser(stream.get(), 0);
+ parser.InitParser(IFX_MemoryStream::Create(data, 4, false), 0);
EXPECT_EQ("\xab", parser.ReadHexString());
EXPECT_EQ(4, parser.SavePos());
}
@@ -71,10 +61,8 @@ TEST(cpdf_syntax_parser, ReadHexString) {
{
// Skips unknown characters.
uint8_t data[] = "\xffzab";
- ScopedFileStream stream(IFX_MemoryStream::Create(data, 4, false));
-
CPDF_SyntaxParser parser;
- parser.InitParser(stream.get(), 0);
+ parser.InitParser(IFX_MemoryStream::Create(data, 4, false), 0);
EXPECT_EQ("\xab", parser.ReadHexString());
EXPECT_EQ(4, parser.SavePos());
}
@@ -82,10 +70,8 @@ TEST(cpdf_syntax_parser, ReadHexString) {
{
// Regular conversion.
uint8_t data[] = "1A2b>abcd";
- ScopedFileStream stream(IFX_MemoryStream::Create(data, 9, false));
-
CPDF_SyntaxParser parser;
- parser.InitParser(stream.get(), 0);
+ parser.InitParser(IFX_MemoryStream::Create(data, 9, false), 0);
EXPECT_EQ("\x1a\x2b", parser.ReadHexString());
EXPECT_EQ(5, parser.SavePos());
}
@@ -93,10 +79,8 @@ TEST(cpdf_syntax_parser, ReadHexString) {
{
// Position out of bounds.
uint8_t data[] = "12ab>";
- ScopedFileStream stream(IFX_MemoryStream::Create(data, 5, false));
-
CPDF_SyntaxParser parser;
- parser.InitParser(stream.get(), 0);
+ parser.InitParser(IFX_MemoryStream::Create(data, 5, false), 0);
parser.RestorePos(5);
EXPECT_EQ("", parser.ReadHexString());
@@ -117,10 +101,8 @@ TEST(cpdf_syntax_parser, ReadHexString) {
{
// Missing ending >.
uint8_t data[] = "1A2b";
- ScopedFileStream stream(IFX_MemoryStream::Create(data, 4, false));
-
CPDF_SyntaxParser parser;
- parser.InitParser(stream.get(), 0);
+ parser.InitParser(IFX_MemoryStream::Create(data, 4, false), 0);
EXPECT_EQ("\x1a\x2b", parser.ReadHexString());
EXPECT_EQ(4, parser.SavePos());
}
@@ -128,10 +110,8 @@ TEST(cpdf_syntax_parser, ReadHexString) {
{
// Missing ending >.
uint8_t data[] = "12abz";
- ScopedFileStream stream(IFX_MemoryStream::Create(data, 5, false));
-
CPDF_SyntaxParser parser;
- parser.InitParser(stream.get(), 0);
+ parser.InitParser(IFX_MemoryStream::Create(data, 5, false), 0);
EXPECT_EQ("\x12\xab", parser.ReadHexString());
EXPECT_EQ(5, parser.SavePos());
}
@@ -139,10 +119,8 @@ TEST(cpdf_syntax_parser, ReadHexString) {
{
// Uneven number of bytes.
uint8_t data[] = "1A2>asdf";
- ScopedFileStream stream(IFX_MemoryStream::Create(data, 8, false));
-
CPDF_SyntaxParser parser;
- parser.InitParser(stream.get(), 0);
+ parser.InitParser(IFX_MemoryStream::Create(data, 8, false), 0);
EXPECT_EQ("\x1a\x20", parser.ReadHexString());
EXPECT_EQ(4, parser.SavePos());
}
@@ -150,10 +128,8 @@ TEST(cpdf_syntax_parser, ReadHexString) {
{
// Uneven number of bytes.
uint8_t data[] = "1A2zasdf";
- ScopedFileStream stream(IFX_MemoryStream::Create(data, 8, false));
-
CPDF_SyntaxParser parser;
- parser.InitParser(stream.get(), 0);
+ parser.InitParser(IFX_MemoryStream::Create(data, 8, false), 0);
EXPECT_EQ("\x1a\x2a\xdf", parser.ReadHexString());
EXPECT_EQ(8, parser.SavePos());
}
@@ -161,10 +137,8 @@ TEST(cpdf_syntax_parser, ReadHexString) {
{
// Just ending character.
uint8_t data[] = ">";
- ScopedFileStream stream(IFX_MemoryStream::Create(data, 1, false));
-
CPDF_SyntaxParser parser;
- parser.InitParser(stream.get(), 0);
+ parser.InitParser(IFX_MemoryStream::Create(data, 1, false), 0);
EXPECT_EQ("", parser.ReadHexString());
EXPECT_EQ(1, parser.SavePos());
}
« no previous file with comments | « core/fpdfapi/parser/cpdf_syntax_parser.cpp ('k') | core/fpdfapi/parser/fpdf_parser_utility.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698