From 1c4735aed9442a8e442214a23a3df94bd8fc99b5 Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Thu, 16 Nov 2017 22:08:07 +0000 Subject: Convert ByteString::{Format|FormatV} to static methods This CL moves the Format and FormatV methods of ByteString to be static. Bug: pdfium:934 Change-Id: I9c30455a789aff9f619b9d5bf89c0712644f2d9a Reviewed-on: https://pdfium-review.googlesource.com/18650 Commit-Queue: dsinclair Reviewed-by: Tom Sepez --- core/fxcrt/bytestring_unittest.cpp | 68 ++++++-------------------------------- 1 file changed, 10 insertions(+), 58 deletions(-) (limited to 'core/fxcrt/bytestring_unittest.cpp') diff --git a/core/fxcrt/bytestring_unittest.cpp b/core/fxcrt/bytestring_unittest.cpp index 4668fe1cc8..08c0e9211c 100644 --- a/core/fxcrt/bytestring_unittest.cpp +++ b/core/fxcrt/bytestring_unittest.cpp @@ -1448,67 +1448,19 @@ TEST(ByteStringView, AnyAllNoneOf) { } TEST(ByteString, FormatWidth) { - { - ByteString str; - str.Format("%5d", 1); - EXPECT_EQ(" 1", str); - } - - { - ByteString str; - str.Format("%d", 1); - EXPECT_EQ("1", str); - } - - { - ByteString str; - str.Format("%*d", 5, 1); - EXPECT_EQ(" 1", str); - } - - { - ByteString str; - str.Format("%-1d", 1); - EXPECT_EQ("1", str); - } - - { - ByteString str; - str.Format("%0d", 1); - EXPECT_EQ("1", str); - } + EXPECT_EQ(" 1", ByteString::Format("%5d", 1)); + EXPECT_EQ("1", ByteString::Format("%d", 1)); + EXPECT_EQ(" 1", ByteString::Format("%*d", 5, 1)); + EXPECT_EQ("1", ByteString::Format("%-1d", 1)); + EXPECT_EQ("1", ByteString::Format("%0d", 1)); } TEST(ByteString, FormatPrecision) { - { - ByteString str; - str.Format("%.2f", 1.12345); - EXPECT_EQ("1.12", str); - } - - { - ByteString str; - str.Format("%.*f", 3, 1.12345); - EXPECT_EQ("1.123", str); - } - - { - ByteString str; - str.Format("%f", 1.12345); - EXPECT_EQ("1.123450", str); - } - - { - ByteString str; - str.Format("%-1f", 1.12345); - EXPECT_EQ("1.123450", str); - } - - { - ByteString str; - str.Format("%0f", 1.12345); - EXPECT_EQ("1.123450", str); - } + EXPECT_EQ("1.12", ByteString::Format("%.2f", 1.12345)); + EXPECT_EQ("1.123", ByteString::Format("%.*f", 3, 1.12345)); + EXPECT_EQ("1.123450", ByteString::Format("%f", 1.12345)); + EXPECT_EQ("1.123450", ByteString::Format("%-1f", 1.12345)); + EXPECT_EQ("1.123450", ByteString::Format("%0f", 1.12345)); } TEST(ByteString, Empty) { -- cgit v1.2.3