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

Unified Diff: core/src/fxcrt/fx_basic_bstring_unittest.cpp

Issue 1421813008: Merge to XFA: Add format width and precision tests. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | core/src/fxcrt/fx_basic_wstring_unittest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/src/fxcrt/fx_basic_bstring_unittest.cpp
diff --git a/core/src/fxcrt/fx_basic_bstring_unittest.cpp b/core/src/fxcrt/fx_basic_bstring_unittest.cpp
index 3779397891182a8ae30b177e1cc7d66439b748d3..d8d880f8b1a337aa61678beb5a5c4a3631821570 100644
--- a/core/src/fxcrt/fx_basic_bstring_unittest.cpp
+++ b/core/src/fxcrt/fx_basic_bstring_unittest.cpp
@@ -603,3 +603,79 @@ TEST(fxcrt, ByteStringCOperatorNE) {
EXPECT_TRUE(c_string2 != byte_string_c);
EXPECT_TRUE(c_string3 != byte_string_c);
}
+
+TEST(fxcrt, ByteStringFormatWidth) {
+ {
+ CFX_ByteString str;
+ str.Format("%5d", 1);
+ EXPECT_EQ(" 1", str);
+ }
+
+ {
+ CFX_ByteString str;
+ str.Format("%d", 1);
+ EXPECT_EQ("1", str);
+ }
+
+ {
+ CFX_ByteString str;
+ str.Format("%*d", 5, 1);
+ EXPECT_EQ(" 1", str);
+ }
+
+ {
+ CFX_ByteString str;
+ str.Format("%-1d", 1);
+ EXPECT_EQ("1", str);
+ }
+
+ {
+ CFX_ByteString str;
+ str.Format("%0d", 1);
+ EXPECT_EQ("1", str);
+ }
+
+ {
+ CFX_ByteString str;
+ str.Format("%1048576d", 1);
+ EXPECT_EQ("Bad width", str);
+ }
+}
+
+TEST(fxcrt, ByteStringFormatPrecision) {
+ {
+ CFX_ByteString str;
+ str.Format("%.2f", 1.12345);
+ EXPECT_EQ("1.12", str);
+ }
+
+ {
+ CFX_ByteString str;
+ str.Format("%.*f", 3, 1.12345);
+ EXPECT_EQ("1.123", str);
+ }
+
+ {
+ CFX_ByteString str;
+ str.Format("%f", 1.12345);
+ EXPECT_EQ("1.123450", str);
+ }
+
+ {
+ CFX_ByteString str;
+ str.Format("%-1f", 1.12345);
+ EXPECT_EQ("1.123450", str);
+ }
+
+ {
+ CFX_ByteString str;
+ str.Format("%0f", 1.12345);
+ EXPECT_EQ("1.123450", str);
+ }
+
+ {
+ CFX_ByteString str;
+ str.Format("%.1048576f", 1.2);
+ EXPECT_EQ("Bad precision", str);
+ }
+}
« 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