Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
cfx_memorystream_unittest.cpp
Go to the documentation of this file.
1
// Copyright 2019 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/fxcrt/cfx_memorystream.h"
6
7
#
include
"core/fxcrt/retain_ptr.h"
8
#
include
"testing/gmock/include/gmock/gmock.h"
9
#
include
"testing/gtest/include/gtest/gtest.h"
10
11
TEST
(
CFXMemoryStreamTest
,
ReadBlockAtOffset
) {
12
auto
stream =
pdfium
::MakeRetain<CFX_MemoryStream>();
13
const
uint8_t kData1[] = {
'a'
,
'b'
,
'c'
,
'd'
,
'e'
,
'f'
};
14
ASSERT_TRUE(stream->WriteBlock(kData1));
15
ASSERT_THAT(stream->GetSpan(),
16
testing::ElementsAre(
'a'
,
'b'
,
'c'
,
'd'
,
'e'
,
'f'
));
17
18
uint8_t buffer[3];
19
ASSERT_TRUE(stream->ReadBlockAtOffset(buffer, 2));
20
ASSERT_THAT(buffer, testing::ElementsAre(
'c'
,
'd'
,
'e'
));
21
22
ASSERT_TRUE(stream->ReadBlockAtOffset(buffer, 0));
23
ASSERT_THAT(buffer, testing::ElementsAre(
'a'
,
'b'
,
'c'
));
24
25
ASSERT_TRUE(stream->ReadBlockAtOffset(buffer, 3));
26
ASSERT_THAT(buffer, testing::ElementsAre(
'd'
,
'e'
,
'f'
));
27
28
ASSERT_FALSE(stream->ReadBlockAtOffset(buffer, 4));
29
ASSERT_THAT(buffer, testing::ElementsAre(
'd'
,
'e'
,
'f'
));
30
}
31
32
TEST
(
CFXMemoryStreamTest
,
WriteBlock
) {
33
auto
stream =
pdfium
::MakeRetain<CFX_MemoryStream>();
34
ASSERT_TRUE(stream->WriteBlock({}));
35
ASSERT_TRUE(stream->GetSpan().empty());
36
37
const
uint8_t kData1[] = {
'a'
,
'b'
,
'c'
};
38
ASSERT_TRUE(stream->WriteBlock(kData1));
39
ASSERT_THAT(stream->GetSpan(), testing::ElementsAre(
'a'
,
'b'
,
'c'
));
40
41
ASSERT_TRUE(stream->WriteBlock(kData1));
42
ASSERT_THAT(stream->GetSpan(),
43
testing::ElementsAre(
'a'
,
'b'
,
'c'
,
'a'
,
'b'
,
'c'
));
44
45
ASSERT_TRUE(stream->WriteBlock({}));
46
ASSERT_THAT(stream->GetSpan(),
47
testing::ElementsAre(
'a'
,
'b'
,
'c'
,
'a'
,
'b'
,
'c'
));
48
}
49
50
TEST
(
CFXMemoryStreamTest
,
WriteZeroBytes
) {
51
auto
stream =
pdfium
::MakeRetain<CFX_MemoryStream>();
52
const
uint8_t kData1[] = {
'a'
,
'b'
,
'c'
};
53
ASSERT_TRUE(stream->WriteBlock(kData1));
54
ASSERT_THAT(stream->GetSpan(), testing::ElementsAre(
'a'
,
'b'
,
'c'
));
55
56
ASSERT_TRUE(stream->WriteBlock({}));
57
ASSERT_THAT(stream->GetSpan(), testing::ElementsAre(
'a'
,
'b'
,
'c'
));
58
}
pdfium::CFDETextOutLargeBitmapTest
Definition
cfde_textout_unittest.cpp:117
TEST
TEST(FXCRYPT, MD5GenerateEmtpyData)
Definition
fx_crypt_unittest.cpp:50
qtwebengine
src
3rdparty
chromium
third_party
pdfium
core
fxcrt
cfx_memorystream_unittest.cpp
Generated on
for Qt by
1.18.0