summaryrefslogtreecommitdiff
path: root/testing/fx_string_testhelpers.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'testing/fx_string_testhelpers.cpp')
-rw-r--r--testing/fx_string_testhelpers.cpp20
1 files changed, 17 insertions, 3 deletions
diff --git a/testing/fx_string_testhelpers.cpp b/testing/fx_string_testhelpers.cpp
index e2ce9353fb..e3c443ac4e 100644
--- a/testing/fx_string_testhelpers.cpp
+++ b/testing/fx_string_testhelpers.cpp
@@ -24,8 +24,22 @@ CFX_InvalidSeekableReadStream::CFX_InvalidSeekableReadStream(
CFX_InvalidSeekableReadStream::~CFX_InvalidSeekableReadStream() = default;
CFX_BufferSeekableReadStream::CFX_BufferSeekableReadStream(
- const unsigned char* src,
- size_t src_size)
- : data_(src), data_size_(src_size) {}
+ pdfium::span<const uint8_t> data)
+ : data_(data) {}
CFX_BufferSeekableReadStream::~CFX_BufferSeekableReadStream() = default;
+
+bool CFX_BufferSeekableReadStream::ReadBlock(void* buffer,
+ FX_FILESIZE offset,
+ size_t size) {
+ if (offset < 0 || static_cast<size_t>(offset) >= data_.size())
+ return false;
+
+ if (static_cast<size_t>(offset) + size > data_.size())
+ size = data_.size() - static_cast<size_t>(offset);
+ if (size == 0)
+ return false;
+
+ memcpy(buffer, &data_[offset], size);
+ return true;
+}