Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(147)

Side by Side Diff: core/src/fxcrt/fx_basic_wstring_unittest.cpp

Issue 860973002: Simplify UTF16LE_Encode and add unittest. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: tab Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « core/src/fxcrt/fx_basic_wstring.cpp ('k') | fpdfsdk/src/fpdfdoc.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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 #include "testing/gtest/include/gtest/gtest.h"
6 #include "../../../testing/fx_string_testhelpers.h"
7 #include "../../include/fxcrt/fx_basic.h"
8
9 #define ByteStringLiteral(str) CFX_ByteString(FX_BSTRC(str))
10
11 TEST(fxcrt, WideStringUTF16LE_Encode) {
12 struct UTF16LEEncodeCase {
13 CFX_WideString ws;
14 CFX_ByteString bs;
15 } utf16le_encode_cases[] = {
16 { L"", ByteStringLiteral("\0\0") },
17 { L"abc", ByteStringLiteral("a\0b\0c\0\0\0") },
18 { L"abcdef", ByteStringLiteral("a\0b\0c\0d\0e\0f\0\0\0") },
19 { L"abc\0def", ByteStringLiteral("a\0b\0c\0\0\0") },
20 { L"\xaabb\xccdd", ByteStringLiteral("\xbb\xaa\xdd\xcc\0\0") },
21 { L"\x3132\x6162", ByteStringLiteral("\x32\x31\x62\x61\0\0") },
22 };
23
24 for (size_t i = 0; i < FX_ArraySize(utf16le_encode_cases); ++i) {
25 EXPECT_EQ(utf16le_encode_cases[i].bs,
26 utf16le_encode_cases[i].ws.UTF16LE_Encode())
27 << " for case number " << i;
28 }
29 }
OLDNEW
« no previous file with comments | « core/src/fxcrt/fx_basic_wstring.cpp ('k') | fpdfsdk/src/fpdfdoc.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698