| 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 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 433 const wchar_t* c_string2 = L"hellp"; | 433 const wchar_t* c_string2 = L"hellp"; |
| 434 const wchar_t* c_string3 = L"hellod"; | 434 const wchar_t* c_string3 = L"hellod"; |
| 435 EXPECT_TRUE(wide_string_c != c_string1); | 435 EXPECT_TRUE(wide_string_c != c_string1); |
| 436 EXPECT_TRUE(wide_string_c != c_string2); | 436 EXPECT_TRUE(wide_string_c != c_string2); |
| 437 EXPECT_TRUE(wide_string_c != c_string3); | 437 EXPECT_TRUE(wide_string_c != c_string3); |
| 438 | 438 |
| 439 EXPECT_TRUE(c_string1 != wide_string_c); | 439 EXPECT_TRUE(c_string1 != wide_string_c); |
| 440 EXPECT_TRUE(c_string2 != wide_string_c); | 440 EXPECT_TRUE(c_string2 != wide_string_c); |
| 441 EXPECT_TRUE(c_string3 != wide_string_c); | 441 EXPECT_TRUE(c_string3 != wide_string_c); |
| 442 } | 442 } |
| 443 |
| 444 TEST(fxcrt, WideStringFormatWidth) { |
| 445 { |
| 446 CFX_WideString str; |
| 447 str.Format(L"%5d", 1); |
| 448 EXPECT_EQ(L" 1", str); |
| 449 } |
| 450 |
| 451 { |
| 452 CFX_WideString str; |
| 453 str.Format(L"%d", 1); |
| 454 EXPECT_EQ(L"1", str); |
| 455 } |
| 456 |
| 457 { |
| 458 CFX_WideString str; |
| 459 str.Format(L"%*d", 5, 1); |
| 460 EXPECT_EQ(L" 1", str); |
| 461 } |
| 462 |
| 463 { |
| 464 CFX_WideString str; |
| 465 str.Format(L"%-1d", 1); |
| 466 EXPECT_EQ(L"1", str); |
| 467 } |
| 468 |
| 469 { |
| 470 CFX_WideString str; |
| 471 str.Format(L"%0d", 1); |
| 472 EXPECT_EQ(L"1", str); |
| 473 } |
| 474 |
| 475 { |
| 476 CFX_WideString str; |
| 477 str.Format(L"%1048576d", 1); |
| 478 EXPECT_EQ(L"Bad width", str); |
| 479 } |
| 480 } |
| 481 |
| 482 TEST(fxcrt, WideStringFormatPrecision) { |
| 483 { |
| 484 CFX_WideString str; |
| 485 str.Format(L"%.2f", 1.12345); |
| 486 EXPECT_EQ(L"1.12", str); |
| 487 } |
| 488 |
| 489 { |
| 490 CFX_WideString str; |
| 491 str.Format(L"%.*f", 3, 1.12345); |
| 492 EXPECT_EQ(L"1.123", str); |
| 493 } |
| 494 |
| 495 { |
| 496 CFX_WideString str; |
| 497 str.Format(L"%f", 1.12345); |
| 498 EXPECT_EQ(L"1.123450", str); |
| 499 } |
| 500 |
| 501 { |
| 502 CFX_WideString str; |
| 503 str.Format(L"%-1f", 1.12345); |
| 504 EXPECT_EQ(L"1.123450", str); |
| 505 } |
| 506 |
| 507 { |
| 508 CFX_WideString str; |
| 509 str.Format(L"%0f", 1.12345); |
| 510 EXPECT_EQ(L"1.123450", str); |
| 511 } |
| 512 |
| 513 { |
| 514 CFX_WideString str; |
| 515 str.Format(L"%.1048576f", 1.2); |
| 516 EXPECT_EQ(L"Bad precision", str); |
| 517 } |
| 518 } |
| OLD | NEW |