pdfium/testing/test_loader.cpp
Lei Zhang 306320700e Add third_party/base/check.h and notreached.h.
Split part of logging.h into check.h and notreached.h, just like in
Chromium. Change many files that directly call
CHECK()/DCHECK()/NOTREACHED(), but not other logging.h macros, to
include check.h and/or notreached.h instead.

Bug: pdfium:1594
Change-Id: Ide80bd66257f5f267863c36ad0268bbb63225742
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/74275
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
2020-10-02 01:57:54 +00:00

27 lines
733 B
C++

// Copyright 2019 PDFium Authors. All rights reserved.
// 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;
}