1 // Copyright 2014 The PDFium Authors 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 8 #include <iosfwd> 9 #include <memory> 10 #include <string> 11 #include <vector> 12 13 #include "public/fpdfview.h" 14 #include "testing/free_deleter.h" 15 16 class CFX_DateTime; 17 18 // Output stream operator so GTEST macros work with CFX_DateTime objects. 19 std::ostream& operator<<(std::ostream& os, const CFX_DateTime& dt); 20 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 31 using ScopedFPDFWideString = std::unique_ptr<FPDF_WCHAR, pdfium::FreeDeleter>; 32 33 // Returns a newly allocated FPDF_WIDESTRING. 34 // Deals with differences between UTF16LE and wchar_t. 35 ScopedFPDFWideString GetFPDFWideString(const std::wstring& wstr); 36 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 41 #endif // TESTING_FX_STRING_TESTHELPERS_H_ 42