Henrique Nakashima | b9776c7 | 2017-06-23 15:03:50 -0400 | [diff] [blame] | 1 | // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef TESTING_FX_STRING_TESTHELPERS_H_ |
| 6 | #define TESTING_FX_STRING_TESTHELPERS_H_ |
| 7 | |
Lei Zhang | b6992dd | 2019-02-05 23:30:20 +0000 | [diff] [blame] | 8 | #include <memory> |
Henrique Nakashima | b9776c7 | 2017-06-23 15:03:50 -0400 | [diff] [blame] | 9 | #include <ostream> |
Lei Zhang | b6992dd | 2019-02-05 23:30:20 +0000 | [diff] [blame] | 10 | #include <string> |
| 11 | #include <vector> |
Henrique Nakashima | b9776c7 | 2017-06-23 15:03:50 -0400 | [diff] [blame] | 12 | |
Lei Zhang | b6992dd | 2019-02-05 23:30:20 +0000 | [diff] [blame] | 13 | #include "public/fpdfview.h" |
| 14 | #include "testing/free_deleter.h" |
Henrique Nakashima | b9776c7 | 2017-06-23 15:03:50 -0400 | [diff] [blame] | 15 | |
Lei Zhang | 423d99b | 2021-03-30 21:11:54 +0000 | [diff] [blame] | 16 | class CFX_DateTime; |
| 17 | |
Henrique Nakashima | b9776c7 | 2017-06-23 15:03:50 -0400 | [diff] [blame] | 18 | // Output stream operator so GTEST macros work with CFX_DateTime objects. |
| 19 | std::ostream& operator<<(std::ostream& os, const CFX_DateTime& dt); |
| 20 | |
Lei Zhang | b6992dd | 2019-02-05 23:30:20 +0000 | [diff] [blame] | 21 | std::vector<std::string> StringSplit(const std::string& str, char delimiter); |
| 22 | |
| 23 | // Converts a FPDF_WIDESTRING to a std::string. |
| 24 | // Deals with differences between UTF16LE and UTF8. |
| 25 | std::string GetPlatformString(FPDF_WIDESTRING wstr); |
| 26 | |
| 27 | // Converts a FPDF_WIDESTRING to a std::wstring. |
| 28 | // Deals with differences between UTF16LE and wchar_t. |
| 29 | std::wstring GetPlatformWString(FPDF_WIDESTRING wstr); |
| 30 | |
Lei Zhang | f0f6768 | 2019-04-08 17:03:21 +0000 | [diff] [blame] | 31 | using ScopedFPDFWideString = std::unique_ptr<FPDF_WCHAR, pdfium::FreeDeleter>; |
| 32 | |
Lei Zhang | b6992dd | 2019-02-05 23:30:20 +0000 | [diff] [blame] | 33 | // Returns a newly allocated FPDF_WIDESTRING. |
| 34 | // Deals with differences between UTF16LE and wchar_t. |
Lei Zhang | f0f6768 | 2019-04-08 17:03:21 +0000 | [diff] [blame] | 35 | ScopedFPDFWideString GetFPDFWideString(const std::wstring& wstr); |
Lei Zhang | b6992dd | 2019-02-05 23:30:20 +0000 | [diff] [blame] | 36 | |
Lei Zhang | 5bf8c7f | 2019-04-08 17:50:11 +0000 | [diff] [blame] | 37 | // Returns a FPDF_WCHAR vector of |length_bytes| bytes. |length_bytes| must be a |
| 38 | // multiple of sizeof(FPDF_WCHAR). |
| 39 | std::vector<FPDF_WCHAR> GetFPDFWideStringBuffer(size_t length_bytes); |
| 40 | |
Henrique Nakashima | b9776c7 | 2017-06-23 15:03:50 -0400 | [diff] [blame] | 41 | #endif // TESTING_FX_STRING_TESTHELPERS_H_ |