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 "testing/gtest/include/gtest/gtest.h" | 5 #include "testing/gtest/include/gtest/gtest.h" |
6 #include "../../../testing/fx_string_testhelpers.h" | 6 #include "../../../testing/fx_string_testhelpers.h" |
7 #include "../../include/fxcrt/fx_basic.h" | 7 #include "../../include/fxcrt/fx_basic.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 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 const wchar_t* c_string2 = L"hellp"; | 242 const wchar_t* c_string2 = L"hellp"; |
243 const wchar_t* c_string3 = L"hellod"; | 243 const wchar_t* c_string3 = L"hellod"; |
244 EXPECT_TRUE(wide_string != c_string1); | 244 EXPECT_TRUE(wide_string != c_string1); |
245 EXPECT_TRUE(wide_string != c_string2); | 245 EXPECT_TRUE(wide_string != c_string2); |
246 EXPECT_TRUE(wide_string != c_string3); | 246 EXPECT_TRUE(wide_string != c_string3); |
247 EXPECT_TRUE(c_string1 != wide_string); | 247 EXPECT_TRUE(c_string1 != wide_string); |
248 EXPECT_TRUE(c_string2 != wide_string); | 248 EXPECT_TRUE(c_string2 != wide_string); |
249 EXPECT_TRUE(c_string3 != wide_string); | 249 EXPECT_TRUE(c_string3 != wide_string); |
250 } | 250 } |
251 | 251 |
| 252 TEST(fxcrt, WideStringConcatInPlace) { |
| 253 CFX_WideString fred; |
| 254 fred.ConcatInPlace(4, L"FRED"); |
| 255 EXPECT_EQ(L"FRED", fred); |
| 256 |
| 257 fred.ConcatInPlace(2, L"DY"); |
| 258 EXPECT_EQ(L"FREDDY", fred); |
| 259 |
| 260 fred.Delete(3, 3); |
| 261 EXPECT_EQ(L"FRE", fred); |
| 262 |
| 263 fred.ConcatInPlace(1, L"D"); |
| 264 EXPECT_EQ(L"FRED", fred); |
| 265 |
| 266 CFX_WideString copy = fred; |
| 267 fred.ConcatInPlace(2, L"DY"); |
| 268 EXPECT_EQ(L"FREDDY", fred); |
| 269 EXPECT_EQ(L"FRED", copy); |
| 270 |
| 271 // Test invalid arguments. |
| 272 copy = fred; |
| 273 fred.ConcatInPlace(-6, L"freddy"); |
| 274 CFX_WideString not_aliased(L"xxxxxx"); |
| 275 EXPECT_EQ(L"FREDDY", fred); |
| 276 EXPECT_EQ(L"xxxxxx", not_aliased); |
| 277 } |
| 278 |
252 #define ByteStringLiteral(str) CFX_ByteString(FX_BSTRC(str)) | 279 #define ByteStringLiteral(str) CFX_ByteString(FX_BSTRC(str)) |
253 | 280 |
254 TEST(fxcrt, WideStringUTF16LE_Encode) { | 281 TEST(fxcrt, WideStringUTF16LE_Encode) { |
255 struct UTF16LEEncodeCase { | 282 struct UTF16LEEncodeCase { |
256 CFX_WideString ws; | 283 CFX_WideString ws; |
257 CFX_ByteString bs; | 284 CFX_ByteString bs; |
258 } utf16le_encode_cases[] = { | 285 } utf16le_encode_cases[] = { |
259 { L"", ByteStringLiteral("\0\0") }, | 286 { L"", ByteStringLiteral("\0\0") }, |
260 { L"abc", ByteStringLiteral("a\0b\0c\0\0\0") }, | 287 { L"abc", ByteStringLiteral("a\0b\0c\0\0\0") }, |
261 { L"abcdef", ByteStringLiteral("a\0b\0c\0d\0e\0f\0\0\0") }, | 288 { L"abcdef", ByteStringLiteral("a\0b\0c\0d\0e\0f\0\0\0") }, |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
406 const wchar_t* c_string2 = L"hellp"; | 433 const wchar_t* c_string2 = L"hellp"; |
407 const wchar_t* c_string3 = L"hellod"; | 434 const wchar_t* c_string3 = L"hellod"; |
408 EXPECT_TRUE(wide_string_c != c_string1); | 435 EXPECT_TRUE(wide_string_c != c_string1); |
409 EXPECT_TRUE(wide_string_c != c_string2); | 436 EXPECT_TRUE(wide_string_c != c_string2); |
410 EXPECT_TRUE(wide_string_c != c_string3); | 437 EXPECT_TRUE(wide_string_c != c_string3); |
411 | 438 |
412 EXPECT_TRUE(c_string1 != wide_string_c); | 439 EXPECT_TRUE(c_string1 != wide_string_c); |
413 EXPECT_TRUE(c_string2 != wide_string_c); | 440 EXPECT_TRUE(c_string2 != wide_string_c); |
414 EXPECT_TRUE(c_string3 != wide_string_c); | 441 EXPECT_TRUE(c_string3 != wide_string_c); |
415 } | 442 } |
OLD | NEW |