| OLD | NEW |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "core/include/fxcrt/fx_basic.h" | 5 #include "core/include/fxcrt/fx_basic.h" |
| 6 #include "testing/fx_string_testhelpers.h" | 6 #include "testing/fx_string_testhelpers.h" |
| 7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
| 8 | 8 |
| 9 TEST(fxcrt, WideStringOperatorSubscript) { | 9 TEST(fxcrt, WideStringOperatorSubscript) { |
| 10 // CFX_WideString includes the NUL terminator for non-empty strings. | 10 // CFX_WideString includes the NUL terminator for non-empty strings. |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 EXPECT_EQ(L"xxxxxx", not_aliased); | 276 EXPECT_EQ(L"xxxxxx", not_aliased); |
| 277 } | 277 } |
| 278 | 278 |
| 279 #define ByteStringLiteral(str) CFX_ByteString(FX_BSTRC(str)) | 279 #define ByteStringLiteral(str) CFX_ByteString(FX_BSTRC(str)) |
| 280 | 280 |
| 281 TEST(fxcrt, WideStringUTF16LE_Encode) { | 281 TEST(fxcrt, WideStringUTF16LE_Encode) { |
| 282 struct UTF16LEEncodeCase { | 282 struct UTF16LEEncodeCase { |
| 283 CFX_WideString ws; | 283 CFX_WideString ws; |
| 284 CFX_ByteString bs; | 284 CFX_ByteString bs; |
| 285 } utf16le_encode_cases[] = { | 285 } utf16le_encode_cases[] = { |
| 286 {L"", ByteStringLiteral("")}, | 286 {L"", ByteStringLiteral("\0\0")}, |
| 287 {L"abc", ByteStringLiteral("a\0b\0c\0")}, | 287 {L"abc", ByteStringLiteral("a\0b\0c\0\0\0")}, |
| 288 {L"abcdef", ByteStringLiteral("a\0b\0c\0d\0e\0f\0")}, | 288 {L"abcdef", ByteStringLiteral("a\0b\0c\0d\0e\0f\0\0\0")}, |
| 289 {L"abc\0def", ByteStringLiteral("a\0b\0c\0")}, | 289 {L"abc\0def", ByteStringLiteral("a\0b\0c\0\0\0")}, |
| 290 {L"\xaabb\xccdd", ByteStringLiteral("\xbb\xaa\xdd\xcc")}, | 290 {L"\xaabb\xccdd", ByteStringLiteral("\xbb\xaa\xdd\xcc\0\0")}, |
| 291 {L"\x3132\x6162", ByteStringLiteral("\x32\x31\x62\x61")}, | 291 {L"\x3132\x6162", ByteStringLiteral("\x32\x31\x62\x61\0\0")}, |
| 292 }; | 292 }; |
| 293 | 293 |
| 294 for (size_t i = 0; i < FX_ArraySize(utf16le_encode_cases); ++i) { | 294 for (size_t i = 0; i < FX_ArraySize(utf16le_encode_cases); ++i) { |
| 295 EXPECT_EQ(utf16le_encode_cases[i].bs, | 295 EXPECT_EQ(utf16le_encode_cases[i].bs, |
| 296 utf16le_encode_cases[i].ws.UTF16LE_Encode()) | 296 utf16le_encode_cases[i].ws.UTF16LE_Encode()) |
| 297 << " for case number " << i; | 297 << " for case number " << i; |
| 298 } | 298 } |
| 299 } | 299 } |
| 300 | 300 |
| 301 TEST(fxcrt, WideStringCOperatorSubscript) { | 301 TEST(fxcrt, WideStringCOperatorSubscript) { |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 517 } | 517 } |
| 518 } | 518 } |
| 519 | 519 |
| 520 TEST(fxcrt, EmptyWideString) { | 520 TEST(fxcrt, EmptyWideString) { |
| 521 CFX_WideString empty_str; | 521 CFX_WideString empty_str; |
| 522 EXPECT_TRUE(empty_str.IsEmpty()); | 522 EXPECT_TRUE(empty_str.IsEmpty()); |
| 523 EXPECT_EQ(0, empty_str.GetLength()); | 523 EXPECT_EQ(0, empty_str.GetLength()); |
| 524 const FX_WCHAR* cstr = empty_str.c_str(); | 524 const FX_WCHAR* cstr = empty_str.c_str(); |
| 525 EXPECT_EQ(0, FXSYS_wcslen(cstr)); | 525 EXPECT_EQ(0, FXSYS_wcslen(cstr)); |
| 526 } | 526 } |
| OLD | NEW |