• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
8 #include <memory>
9 #include <ostream>
10 #include <string>
11 #include <vector>
12 
13 #include "core/fxcrt/cfx_datetime.h"
14 #include "public/fpdfview.h"
15 #include "testing/free_deleter.h"
16 
17 // Output stream operator so GTEST macros work with CFX_DateTime objects.
18 std::ostream& operator<<(std::ostream& os, const CFX_DateTime& dt);
19 
20 std::vector<std::string> StringSplit(const std::string& str, char delimiter);
21 
22 // Converts a FPDF_WIDESTRING to a std::string.
23 // Deals with differences between UTF16LE and UTF8.
24 std::string GetPlatformString(FPDF_WIDESTRING wstr);
25 
26 // Converts a FPDF_WIDESTRING to a std::wstring.
27 // Deals with differences between UTF16LE and wchar_t.
28 std::wstring GetPlatformWString(FPDF_WIDESTRING wstr);
29 
30 using ScopedFPDFWideString = std::unique_ptr<FPDF_WCHAR, pdfium::FreeDeleter>;
31 
32 // Returns a newly allocated FPDF_WIDESTRING.
33 // Deals with differences between UTF16LE and wchar_t.
34 ScopedFPDFWideString GetFPDFWideString(const std::wstring& wstr);
35 
36 // Returns a FPDF_WCHAR vector of |length_bytes| bytes. |length_bytes| must be a
37 // multiple of sizeof(FPDF_WCHAR).
38 std::vector<FPDF_WCHAR> GetFPDFWideStringBuffer(size_t length_bytes);
39 
40 #endif  // TESTING_FX_STRING_TESTHELPERS_H_
41