| 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
|
| index 3b15006d655f8019f6906406d8147d09bd271af7..ee010f281898e02d773c2d3fa61bc382c41517c5 100644
|
| --- a/core/src/fxcrt/fx_basic_wstring_unittest.cpp
|
| +++ b/core/src/fxcrt/fx_basic_wstring_unittest.cpp
|
| @@ -6,6 +6,23 @@
|
| #include "../../../testing/fx_string_testhelpers.h"
|
| #include "../../include/fxcrt/fx_basic.h"
|
|
|
| +TEST(fxcrt, WideStringNotNull) {
|
| + // Prove constructor uses sizeof(), not strlen() against literals.
|
| + CFX_WideString literal_string(L"ab\0c");
|
| + EXPECT_EQ(4, literal_string.GetLength());
|
| +
|
| + // Prove constructor uses strlen(), not sizeof() against mutable arrays.
|
| + wchar_t array[32];
|
| + memcpy(array, L"ab\0c", 5 * sizeof(wchar_t));
|
| + CFX_WideString array_string(array);
|
| + EXPECT_EQ(2, array_string.GetLength());
|
| +
|
| + // Prove constructor uses strlen(), not sizeof() against pointers.
|
| + const wchar_t* ptr = L"ab\0c";
|
| + CFX_WideString pointer_string(ptr);
|
| + EXPECT_EQ(2, pointer_string.GetLength());
|
| +}
|
| +
|
| TEST(fxcrt, WideStringOperatorSubscript) {
|
| // CFX_WideString includes the NUL terminator for non-empty strings.
|
| CFX_WideString abc(L"abc");
|
| @@ -170,6 +187,23 @@ TEST(fxcrt, WideStringUTF16LE_Encode) {
|
| }
|
| }
|
|
|
| +TEST(fxcrt, WideStringCNotNull) {
|
| + // Prove constructor uses sizeof(), not strlen() against literals.
|
| + CFX_WideStringC literal_string(L"ab\0c");
|
| + EXPECT_EQ(4, literal_string.GetLength());
|
| +
|
| + // Prove constructor uses strlen(), not sizeof() against mutable arrays.
|
| + wchar_t array[32];
|
| + memcpy(array, L"ab\0c", 5 * sizeof(wchar_t));
|
| + CFX_WideStringC array_string(array);
|
| + EXPECT_EQ(2, array_string.GetLength());
|
| +
|
| + // Prove constructor uses strlen(), not sizeof() against pointers.
|
| + const wchar_t* ptr = L"ab\0c";
|
| + CFX_WideStringC pointer_string(ptr);
|
| + EXPECT_EQ(2, pointer_string.GetLength());
|
| +}
|
| +
|
| TEST(fxcrt, WideStringCOperatorSubscript) {
|
| // CFX_WideStringC includes the NUL terminator for non-empty strings.
|
| CFX_WideStringC abc(L"abc");
|
|
|