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_stream_acc_unittest.cpp
Go to the documentation of this file.
1// Copyright 2018 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/parser/cpdf_stream_acc.h"
6
7#include <algorithm>
8#include <utility>
9
10#include "core/fpdfapi/parser/cpdf_dictionary.h"
11#include "core/fpdfapi/parser/cpdf_stream.h"
12#include "core/fxcrt/fx_stream.h"
13#include "testing/gtest/include/gtest/gtest.h"
14#include "testing/invalid_seekable_read_stream.h"
15
17 auto stream = pdfium::MakeRetain<CPDF_Stream>();
18 stream->InitStreamFromFile(
19 pdfium::MakeRetain<InvalidSeekableReadStream>(1024),
20 pdfium::MakeRetain<CPDF_Dictionary>());
21 auto stream_acc = pdfium::MakeRetain<CPDF_StreamAcc>(std::move(stream));
22 stream_acc->LoadAllDataRaw();
23 EXPECT_TRUE(stream_acc->GetSpan().empty());
24}
25
26// Regression test for crbug.com/1361849. Should not trigger dangling pointer
27// failure with UnownedPtr.
29 constexpr uint8_t kData[] = {'a', 'b', 'c'};
30 auto stream = pdfium::MakeRetain<CPDF_Stream>();
31 stream->SetData(kData);
32 auto stream_acc = pdfium::MakeRetain<CPDF_StreamAcc>(stream);
33 stream_acc->LoadAllDataRaw();
34 stream.Reset();
35 auto span = stream_acc->GetSpan();
36 EXPECT_TRUE(
37 std::equal(std::begin(kData), std::end(kData), span.begin(), span.end()));
38}
TEST(FXCRYPT, MD5GenerateEmtpyData)