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

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: Format 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 TEST(fxcrt, WideStringUTF16LE_Encode) {
10 CFX_WideString wide_strings[] = {
11 L"",
12 L"abc",
13 L"abcdef",
14 L"abc\0def",
15 L"23\0456",
Tom Sepez 2015/01/21 18:15:54 beware of tailing digits following a \0, the inten
Bo Xu 2015/01/21 19:23:55 Done.
16 L"\x3132\x6162" // This is wrong? Endianness matters here?
Tom Sepez 2015/01/21 18:15:54 So, what you'd have here is a wide string: U+313
Bo Xu 2015/01/21 19:23:55 Oh, right, i see.
17 };
18 CFX_ByteString byte_strings[] = {
Tom Sepez 2015/01/21 18:15:54 nit: its preferable to make a single array of stru
Bo Xu 2015/01/21 19:23:55 Done.
19 CFX_ByteString(FX_BSTRC("\0\0")),
20 CFX_ByteString(FX_BSTRC("a\0b\0c\0\0\0")),
21 CFX_ByteString(FX_BSTRC("a\0b\0c\0d\0e\0f\0\0\0")),
22 CFX_ByteString(FX_BSTRC("a\0b\0c\0\0\0")),
23 CFX_ByteString(FX_BSTRC("\x32\x00\x33\x00\045\x00\x36\x00\x00\x00")),
24 CFX_ByteString(FX_BSTRC("12ab\0\0"))
25 };
26 for (size_t i = 0; i < FX_ArraySize(wide_strings); ++i) {
27 EXPECT_EQ(byte_strings[i], wide_strings[i].UTF16LE_Encode())
28 << " for case number " << i;
29 }
30 }
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