Chromium Code Reviews| Index: core/src/fxcrt/fx_basic_wstring_unittest.cpp |
| diff --git a/core/src/fxcrt/fx_basic_wstring_unittest.cpp b/core/src/fxcrt/fx_basic_wstring_unittest.cpp |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..cd6dc1dc6650b55eb43bc2dab0b1e2896705c7ab |
| --- /dev/null |
| +++ b/core/src/fxcrt/fx_basic_wstring_unittest.cpp |
| @@ -0,0 +1,30 @@ |
| +// Copyright 2014 PDFium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "testing/gtest/include/gtest/gtest.h" |
| +#include "../../../testing/fx_string_testhelpers.h" |
| +#include "../../include/fxcrt/fx_basic.h" |
| + |
| +TEST(fxcrt, WideStringUTF16LE_Encode) { |
| + CFX_WideString wide_strings[] = { |
| + L"", |
| + L"abc", |
| + L"abcdef", |
| + L"abc\0def", |
| + 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.
|
| + 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.
|
| + }; |
| + 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.
|
| + CFX_ByteString(FX_BSTRC("\0\0")), |
| + CFX_ByteString(FX_BSTRC("a\0b\0c\0\0\0")), |
| + CFX_ByteString(FX_BSTRC("a\0b\0c\0d\0e\0f\0\0\0")), |
| + CFX_ByteString(FX_BSTRC("a\0b\0c\0\0\0")), |
| + CFX_ByteString(FX_BSTRC("\x32\x00\x33\x00\045\x00\x36\x00\x00\x00")), |
| + CFX_ByteString(FX_BSTRC("12ab\0\0")) |
| + }; |
| + for (size_t i = 0; i < FX_ArraySize(wide_strings); ++i) { |
| + EXPECT_EQ(byte_strings[i], wide_strings[i].UTF16LE_Encode()) |
| + << " for case number " << i; |
| + } |
| +} |