Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
cpdf_streamparser_unittest.cpp
Go to the documentation of this file.
1// Copyright 2015 The PDFium Authors
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "core/fpdfapi/page/cpdf_streamparser.h"
6#include "testing/gtest/include/gtest/gtest.h"
7
9 {
10 // Position out of bounds.
11 uint8_t data[] = "12ab>";
12 CPDF_StreamParser parser(data);
13 parser.SetPos(6);
14 EXPECT_EQ("", parser.ReadHexString());
15 }
16
17 {
18 // Regular conversion.
19 uint8_t data[] = "1A2b>abcd";
20 CPDF_StreamParser parser(data);
21 EXPECT_EQ("\x1a\x2b", parser.ReadHexString());
22 EXPECT_EQ(5u, parser.GetPos());
23 }
24
25 {
26 // Missing ending >
27 uint8_t data[] = "1A2b";
28 CPDF_StreamParser parser(data);
29 EXPECT_EQ("\x1a\x2b", parser.ReadHexString());
30 EXPECT_EQ(5u, parser.GetPos());
31 }
32
33 {
34 // Uneven number of bytes.
35 uint8_t data[] = "1A2>asdf";
36 CPDF_StreamParser parser(data);
37 EXPECT_EQ("\x1a\x20", parser.ReadHexString());
38 EXPECT_EQ(4u, parser.GetPos());
39 }
40
41 {
42 uint8_t data[] = ">";
43 CPDF_StreamParser parser(data);
44 EXPECT_EQ("", parser.ReadHexString());
45 EXPECT_EQ(1u, parser.GetPos());
46 }
47}
void SetPos(uint32_t pos)
uint32_t GetPos() const
TEST(FXCRYPT, MD5GenerateEmtpyData)