aboutsummaryrefslogtreecommitdiff
path: root/testing/fx_string_testhelpers.h
blob: 207947c72ed78e12a6229c5fd83715455d117c3f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// Copyright 2014 The PDFium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef TESTING_FX_STRING_TESTHELPERS_H_
#define TESTING_FX_STRING_TESTHELPERS_H_

#include <iosfwd>
#include <memory>
#include <string>
#include <vector>

#include "public/fpdfview.h"
#include "testing/free_deleter.h"

class CFX_DateTime;

// Output stream operator so GTEST macros work with CFX_DateTime objects.
std::ostream& operator<<(std::ostream& os, const CFX_DateTime& dt);

std::vector<std::string> StringSplit(const std::string& str, char delimiter);

// Converts a FPDF_WIDESTRING to a std::string.
// Deals with differences between UTF16LE and UTF8.
std::string GetPlatformString(FPDF_WIDESTRING wstr);

// Converts a FPDF_WIDESTRING to a std::wstring.
// Deals with differences between UTF16LE and wchar_t.
std::wstring GetPlatformWString(FPDF_WIDESTRING wstr);

using ScopedFPDFWideString = std::unique_ptr<FPDF_WCHAR, pdfium::FreeDeleter>;

// Returns a newly allocated FPDF_WIDESTRING.
// Deals with differences between UTF16LE and wchar_t.
ScopedFPDFWideString GetFPDFWideString(const std::wstring& wstr);

// Returns a FPDF_WCHAR vector of |length_bytes| bytes. |length_bytes| must be a
// multiple of sizeof(FPDF_WCHAR).
std::vector<FPDF_WCHAR> GetFPDFWideStringBuffer(size_t length_bytes);

#endif  // TESTING_FX_STRING_TESTHELPERS_H_