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/gmock/include/gmock/gmock.h"
7#include "testing/gtest/include/gtest/gtest.h"
8
9using testing::ElementsAre;
10using testing::IsEmpty;
11
13 {
14 // Position out of bounds.
15 uint8_t data[] = "12ab>";
16 CPDF_StreamParser parser(data);
17 parser.SetPos(6);
18 EXPECT_THAT(parser.ReadHexString(), IsEmpty());
19 }
20
21 {
22 // Regular conversion.
23 uint8_t data[] = "1A2b>abcd";
24 CPDF_StreamParser parser(data);
25 EXPECT_THAT(parser.ReadHexString(), ElementsAre(0x1a, 0x2b));
26 EXPECT_EQ(5u, parser.GetPos());
27 }
28
29 {
30 // Missing ending >
31 uint8_t data[] = "1A2b";
32 CPDF_StreamParser parser(data);
33 EXPECT_THAT(parser.ReadHexString(), ElementsAre(0x1a, 0x2b));
34 EXPECT_EQ(5u, parser.GetPos());
35 }
36
37 {
38 // Uneven number of bytes.
39 uint8_t data[] = "1A2>asdf";
40 CPDF_StreamParser parser(data);
41 EXPECT_THAT(parser.ReadHexString(), ElementsAre(0x1a, 0x20));
42 EXPECT_EQ(4u, parser.GetPos());
43 }
44
45 {
46 uint8_t data[] = ">";
47 CPDF_StreamParser parser(data);
48 EXPECT_THAT(parser.ReadHexString(), IsEmpty());
49 EXPECT_EQ(1u, parser.GetPos());
50 }
51}
void SetPos(uint32_t pos)
uint32_t GetPos() const
TEST(FXCRYPT, MD5GenerateEmtpyData)