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 "testing/gtest/include/gtest/gtest.h"
12#include "third_party/base/containers/span.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, std::size(buffer)));
21}
22
24 const char data[] = "abcd";
25 auto proxy_stream = pdfium::MakeRetain<CFX_SeekableStreamProxy>(
26 pdfium::MakeRetain<CFX_ReadOnlySpanStream>(pdfium::make_span(
27 reinterpret_cast<const uint8_t*>(data), sizeof(data) - 1)));
28
29 wchar_t buffer[16];
30 EXPECT_EQ(0u, proxy_stream->ReadBlock(buffer, std::size(buffer)));
31}
32
34 const char data[] = "\xEF\xBB\xBF*\xC2\xA2*";
35 auto proxy_stream = pdfium::MakeRetain<CFX_SeekableStreamProxy>(
36 pdfium::MakeRetain<CFX_ReadOnlySpanStream>(pdfium::make_span(
37 reinterpret_cast<const uint8_t*>(data), sizeof(data) - 1)));
38
39 wchar_t buffer[16];
40 EXPECT_EQ(3u, proxy_stream->ReadBlock(buffer, std::size(buffer)));
41 EXPECT_EQ(L'*', buffer[0]);
42 EXPECT_EQ(L'\u00A2', buffer[1]);
43 EXPECT_EQ(L'*', buffer[2]);
44}
45
47 const char data[] = "\xFF\xFE\x41\x00\x42\x01";
48 auto proxy_stream = pdfium::MakeRetain<CFX_SeekableStreamProxy>(
49 pdfium::MakeRetain<CFX_ReadOnlySpanStream>(pdfium::make_span(
50 reinterpret_cast<const uint8_t*>(data), sizeof(data) - 1)));
51
52 wchar_t buffer[16];
53 EXPECT_EQ(2u, proxy_stream->ReadBlock(buffer, std::size(buffer)));
54 EXPECT_EQ(L'A', buffer[0]);
55 EXPECT_EQ(L'\u0142', buffer[1]);
56}
57
59 const char data[] = "\xFE\xFF\x00\x41\x01\x42";
60 auto proxy_stream = pdfium::MakeRetain<CFX_SeekableStreamProxy>(
61 pdfium::MakeRetain<CFX_ReadOnlySpanStream>(pdfium::make_span(
62 reinterpret_cast<const uint8_t*>(data), sizeof(data) - 1)));
63
64 wchar_t buffer[16];
65 EXPECT_EQ(2u, proxy_stream->ReadBlock(buffer, std::size(buffer)));
66 EXPECT_EQ(L'A', buffer[0]);
67 EXPECT_EQ(L'\u0142', buffer[1]);
68}
TEST(FXCRYPT, MD5GenerateEmtpyData)