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/fxcrt/include/fx_basic.h" | 5 #include "core/fxcrt/include/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 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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) { | 252 TEST(fxcrt, WideStringConcatInPlace) { |
253 CFX_WideString fred; | 253 CFX_WideString fred; |
254 fred.ConcatInPlace(4, L"FRED"); | 254 fred.Concat(L"FRED", 4); |
255 EXPECT_EQ(L"FRED", fred); | 255 EXPECT_EQ(L"FRED", fred); |
256 | 256 |
257 fred.ConcatInPlace(2, L"DY"); | 257 fred.Concat(L"DY", 2); |
258 EXPECT_EQ(L"FREDDY", fred); | 258 EXPECT_EQ(L"FREDDY", fred); |
259 | 259 |
260 fred.Delete(3, 3); | 260 fred.Delete(3, 3); |
261 EXPECT_EQ(L"FRE", fred); | 261 EXPECT_EQ(L"FRE", fred); |
262 | 262 |
263 fred.ConcatInPlace(1, L"D"); | 263 fred.Concat(L"D", 1); |
264 EXPECT_EQ(L"FRED", fred); | 264 EXPECT_EQ(L"FRED", fred); |
265 | 265 |
266 CFX_WideString copy = fred; | 266 CFX_WideString copy = fred; |
267 fred.ConcatInPlace(2, L"DY"); | 267 fred.Concat(L"DY", 2); |
268 EXPECT_EQ(L"FREDDY", fred); | 268 EXPECT_EQ(L"FREDDY", fred); |
269 EXPECT_EQ(L"FRED", copy); | 269 EXPECT_EQ(L"FRED", copy); |
270 | 270 |
271 // Test invalid arguments. | 271 // Test invalid arguments. |
272 copy = fred; | 272 copy = fred; |
273 fred.ConcatInPlace(-6, L"freddy"); | 273 fred.Concat(L"freddy", -6); |
274 CFX_WideString not_aliased(L"xxxxxx"); | 274 CFX_WideString not_aliased(L"xxxxxx"); |
275 EXPECT_EQ(L"FREDDY", fred); | 275 EXPECT_EQ(L"FREDDY", fred); |
276 EXPECT_EQ(L"xxxxxx", not_aliased); | 276 EXPECT_EQ(L"xxxxxx", not_aliased); |
277 } | 277 } |
278 | 278 |
279 TEST(fxcrt, WideStringRemove) { | 279 TEST(fxcrt, WideStringRemove) { |
280 CFX_WideString freed(L"FREED"); | 280 CFX_WideString freed(L"FREED"); |
281 freed.Remove(L'E'); | 281 freed.Remove(L'E'); |
282 EXPECT_EQ(L"FRD", freed); | 282 EXPECT_EQ(L"FRD", freed); |
283 freed.Remove(L'F'); | 283 freed.Remove(L'F'); |
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
739 } | 739 } |
740 } | 740 } |
741 | 741 |
742 TEST(fxcrt, EmptyWideString) { | 742 TEST(fxcrt, EmptyWideString) { |
743 CFX_WideString empty_str; | 743 CFX_WideString empty_str; |
744 EXPECT_TRUE(empty_str.IsEmpty()); | 744 EXPECT_TRUE(empty_str.IsEmpty()); |
745 EXPECT_EQ(0, empty_str.GetLength()); | 745 EXPECT_EQ(0, empty_str.GetLength()); |
746 const FX_WCHAR* cstr = empty_str.c_str(); | 746 const FX_WCHAR* cstr = empty_str.c_str(); |
747 EXPECT_EQ(0, FXSYS_wcslen(cstr)); | 747 EXPECT_EQ(0, FXSYS_wcslen(cstr)); |
748 } | 748 } |
OLD | NEW |