Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Side by Side Diff: core/src/fxcrt/fx_basic_bstring_unittest.cpp

Issue 1411973005: Add format width and precision tests. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | core/src/fxcrt/fx_basic_wstring_unittest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/fx_string_testhelpers.h" 5 #include "../../../testing/fx_string_testhelpers.h"
6 #include "../../include/fxcrt/fx_string.h" 6 #include "../../include/fxcrt/fx_string.h"
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 8
9 TEST(fxcrt, ByteStringOperatorSubscript) { 9 TEST(fxcrt, ByteStringOperatorSubscript) {
10 // CFX_ByteString includes the NUL terminator for non-empty strings. 10 // CFX_ByteString includes the NUL terminator for non-empty strings.
(...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after
596 const char* c_string2 = "hellp"; 596 const char* c_string2 = "hellp";
597 const char* c_string3 = "hellod"; 597 const char* c_string3 = "hellod";
598 EXPECT_TRUE(byte_string_c != c_string1); 598 EXPECT_TRUE(byte_string_c != c_string1);
599 EXPECT_TRUE(byte_string_c != c_string2); 599 EXPECT_TRUE(byte_string_c != c_string2);
600 EXPECT_TRUE(byte_string_c != c_string3); 600 EXPECT_TRUE(byte_string_c != c_string3);
601 601
602 EXPECT_TRUE(c_string1 != byte_string_c); 602 EXPECT_TRUE(c_string1 != byte_string_c);
603 EXPECT_TRUE(c_string2 != byte_string_c); 603 EXPECT_TRUE(c_string2 != byte_string_c);
604 EXPECT_TRUE(c_string3 != byte_string_c); 604 EXPECT_TRUE(c_string3 != byte_string_c);
605 } 605 }
606
607 TEST(fxcrt, ByteStringFormatWidth) {
608 {
609 CFX_ByteString str;
610 str.Format("%5d", 1);
611 EXPECT_EQ(" 1", str);
612 }
613
614 {
615 CFX_ByteString str;
616 str.Format("%d", 1);
617 EXPECT_EQ("1", str);
618 }
619
620 {
621 CFX_ByteString str;
622 str.Format("%*d", 5, 1);
623 EXPECT_EQ(" 1", str);
624 }
625
626 {
627 CFX_ByteString str;
628 str.Format("%-1d", 1);
629 EXPECT_EQ("1", str);
630 }
631
632 {
633 CFX_ByteString str;
634 str.Format("%0d", 1);
635 EXPECT_EQ("1", str);
636 }
637
638 {
639 CFX_ByteString str;
640 str.Format("%1048576d", 1);
641 EXPECT_EQ("Bad width", str);
642 }
643 }
644
645 TEST(fxcrt, ByteStringFormatPrecision) {
646 {
647 CFX_ByteString str;
648 str.Format("%.2f", 1.12345);
649 EXPECT_EQ("1.12", str);
650 }
651
652 {
653 CFX_ByteString str;
654 str.Format("%.*f", 3, 1.12345);
655 EXPECT_EQ("1.123", str);
656 }
657
658 {
659 CFX_ByteString str;
660 str.Format("%f", 1.12345);
661 EXPECT_EQ("1.123450", str);
662 }
663
664 {
665 CFX_ByteString str;
666 str.Format("%-1f", 1.12345);
667 EXPECT_EQ("1.123450", str);
668 }
669
670 {
671 CFX_ByteString str;
672 str.Format("%0f", 1.12345);
673 EXPECT_EQ("1.123450", str);
674 }
675
676 {
677 CFX_ByteString str;
678 str.Format("%.1048576f", 1.2);
679 EXPECT_EQ("Bad precision", str);
680 }
681 }
OLDNEW
« no previous file with comments | « no previous file | core/src/fxcrt/fx_basic_wstring_unittest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698