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
cfx_seekablestreamproxy_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_seekablestreamproxy.h"
6
7#include <iterator>
8
9#include "core/fxcrt/cfx_read_only_span_stream.h"
10#include "core/fxcrt/retain_ptr.h"
11#include "core/fxcrt/span.h"
12#include "testing/gtest/include/gtest/gtest.h"
13
15 auto proxy_stream = pdfium::MakeRetain<CFX_SeekableStreamProxy>(
16 pdfium::MakeRetain<CFX_ReadOnlySpanStream>(
17 pdfium::span<const uint8_t>()));
18
19 wchar_t buffer[16];
20 EXPECT_EQ(0u, proxy_stream->ReadBlock(buffer));
21}
22
24 ByteStringView data = "abcd";
25 auto proxy_stream = pdfium::MakeRetain<CFX_SeekableStreamProxy>(
26 pdfium::MakeRetain<CFX_ReadOnlySpanStream>(data.unsigned_span()));
27
28 wchar_t buffer[16];
29 EXPECT_EQ(0u, proxy_stream->ReadBlock(buffer));
30}
31
33 ByteStringView data = "\xEF\xBB\xBF*\xC2\xA2*";
34 auto proxy_stream = pdfium::MakeRetain<CFX_SeekableStreamProxy>(
35 pdfium::MakeRetain<CFX_ReadOnlySpanStream>(data.unsigned_span()));
36
37 wchar_t buffer[16];
38 EXPECT_EQ(3u, proxy_stream->ReadBlock(buffer));
39 EXPECT_EQ(L'*', buffer[0]);
40 EXPECT_EQ(L'\u00A2', buffer[1]);
41 EXPECT_EQ(L'*', buffer[2]);
42}
43
45 // Test embedded NUL not ending in NUL.
46 const uint8_t data[] = {0xFF, 0xFE, 0x41, 0x00, 0x42, 0x01};
47 auto proxy_stream = pdfium::MakeRetain<CFX_SeekableStreamProxy>(
48 pdfium::MakeRetain<CFX_ReadOnlySpanStream>(data));
49
50 wchar_t buffer[16];
51 EXPECT_EQ(2u, proxy_stream->ReadBlock(buffer));
52 EXPECT_EQ(L'A', buffer[0]);
53 EXPECT_EQ(L'\u0142', buffer[1]);
54}
55
57 const uint8_t data[] = {0xFE, 0xFF, 0x00, 0x41, 0x01, 0x42};
58 auto proxy_stream = pdfium::MakeRetain<CFX_SeekableStreamProxy>(
59 pdfium::MakeRetain<CFX_ReadOnlySpanStream>(data));
60
61 wchar_t buffer[16];
62 EXPECT_EQ(2u, proxy_stream->ReadBlock(buffer));
63 EXPECT_EQ(L'A', buffer[0]);
64 EXPECT_EQ(L'\u0142', buffer[1]);
65}
TEST(FXCRYPT, MD5GenerateEmtpyData)
fxcrt::ByteStringView ByteStringView