blob: aac8429a03eb94d6d966f997739c3c0ba8ff8f45 [file] [log] [blame]
kumarashishg826308d2023-06-23 13:21:22 +00001// Copyright 2019 The PDFium Authors
Haibo Huang49cc9302020-04-27 16:14:24 -07002// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "testing/test_loader.h"
6
7#include <string.h>
8
kumarashishg826308d2023-06-23 13:21:22 +00009#include "third_party/base/notreached.h"
Haibo Huang49cc9302020-04-27 16:14:24 -070010
11TestLoader::TestLoader(pdfium::span<const char> span) : m_Span(span) {}
12
13// static
14int TestLoader::GetBlock(void* param,
15 unsigned long pos,
16 unsigned char* pBuf,
17 unsigned long size) {
18 TestLoader* pLoader = static_cast<TestLoader*>(param);
19 if (pos + size < pos || pos + size > pLoader->m_Span.size()) {
20 NOTREACHED();
21 return 0;
22 }
23
24 memcpy(pBuf, &pLoader->m_Span[pos], size);
25 return 1;
26}