| OLD | NEW |
| 1 // Copyright 2015 PDFium Authors. All rights reserved. | 1 // Copyright 2015 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "testing/test_support.h" | 5 #include "testing/test_support.h" |
| 6 | 6 |
| 7 #include <stdio.h> | 7 #include <stdio.h> |
| 8 #include <string.h> | 8 #include <string.h> |
| 9 | 9 |
| 10 #include "testing/utils/path_service.h" | 10 #include "testing/utils/path_service.h" |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 unsigned long pos, | 165 unsigned long pos, |
| 166 unsigned char* pBuf, | 166 unsigned char* pBuf, |
| 167 unsigned long size) { | 167 unsigned long size) { |
| 168 TestLoader* pLoader = static_cast<TestLoader*>(param); | 168 TestLoader* pLoader = static_cast<TestLoader*>(param); |
| 169 if (pos + size < pos || pos + size > pLoader->m_Len) | 169 if (pos + size < pos || pos + size > pLoader->m_Len) |
| 170 return 0; | 170 return 0; |
| 171 | 171 |
| 172 memcpy(pBuf, pLoader->m_pBuf + pos, size); | 172 memcpy(pBuf, pLoader->m_pBuf + pos, size); |
| 173 return 1; | 173 return 1; |
| 174 } | 174 } |
| 175 |
| 176 TestSaver::TestSaver() { |
| 177 FPDF_FILEWRITE::version = 1; |
| 178 FPDF_FILEWRITE::WriteBlock = WriteBlockCallback; |
| 179 } |
| 180 |
| 181 void TestSaver::ClearString() { |
| 182 m_String.clear(); |
| 183 } |
| 184 |
| 185 // static |
| 186 int TestSaver::WriteBlockCallback(FPDF_FILEWRITE* pFileWrite, |
| 187 const void* data, |
| 188 unsigned long size) { |
| 189 TestSaver* pThis = static_cast<TestSaver*>(pFileWrite); |
| 190 pThis->m_String.append(static_cast<const char*>(data), size); |
| 191 return 1; |
| 192 } |
| OLD | NEW |