blob: adfa7bd246ac5836e1cc8fd351e98cbc072af79a [file] [log] [blame]
Henrique Nakashimab9776c72017-06-23 15:03:50 -04001// 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 Zhangb6992dd2019-02-05 23:30:20 +00008#include <memory>
Henrique Nakashimab9776c72017-06-23 15:03:50 -04009#include <ostream>
Lei Zhangb6992dd2019-02-05 23:30:20 +000010#include <string>
11#include <vector>
Henrique Nakashimab9776c72017-06-23 15:03:50 -040012
Lei Zhangb6992dd2019-02-05 23:30:20 +000013#include "public/fpdfview.h"
14#include "testing/free_deleter.h"
Henrique Nakashimab9776c72017-06-23 15:03:50 -040015
Lei Zhang423d99b2021-03-30 21:11:54 +000016class CFX_DateTime;
17
Henrique Nakashimab9776c72017-06-23 15:03:50 -040018// Output stream operator so GTEST macros work with CFX_DateTime objects.
19std::ostream& operator<<(std::ostream& os, const CFX_DateTime& dt);
20
Lei Zhangb6992dd2019-02-05 23:30:20 +000021std::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.
25std::string GetPlatformString(FPDF_WIDESTRING wstr);
26
27// Converts a FPDF_WIDESTRING to a std::wstring.
28// Deals with differences between UTF16LE and wchar_t.
29std::wstring GetPlatformWString(FPDF_WIDESTRING wstr);
30
Lei Zhangf0f67682019-04-08 17:03:21 +000031using ScopedFPDFWideString = std::unique_ptr<FPDF_WCHAR, pdfium::FreeDeleter>;
32
Lei Zhangb6992dd2019-02-05 23:30:20 +000033// Returns a newly allocated FPDF_WIDESTRING.
34// Deals with differences between UTF16LE and wchar_t.
Lei Zhangf0f67682019-04-08 17:03:21 +000035ScopedFPDFWideString GetFPDFWideString(const std::wstring& wstr);
Lei Zhangb6992dd2019-02-05 23:30:20 +000036
Lei Zhang5bf8c7f2019-04-08 17:50:11 +000037// Returns a FPDF_WCHAR vector of |length_bytes| bytes. |length_bytes| must be a
38// multiple of sizeof(FPDF_WCHAR).
39std::vector<FPDF_WCHAR> GetFPDFWideStringBuffer(size_t length_bytes);
40
Henrique Nakashimab9776c72017-06-23 15:03:50 -040041#endif // TESTING_FX_STRING_TESTHELPERS_H_