blob: aac8429a03eb94d6d966f997739c3c0ba8ff8f45 [file] [log] [blame]
// Copyright 2019 The PDFium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "testing/test_loader.h"
#include <string.h>
#include "third_party/base/notreached.h"
TestLoader::TestLoader(pdfium::span<const char> span) : m_Span(span) {}
// static
int TestLoader::GetBlock(void* param,
unsigned long pos,
unsigned char* pBuf,
unsigned long size) {
TestLoader* pLoader = static_cast<TestLoader*>(param);
if (pos + size < pos || pos + size > pLoader->m_Span.size()) {
NOTREACHED();
return 0;
}
memcpy(pBuf, &pLoader->m_Span[pos], size);
return 1;
}