From 3f1c832dda209cf6682bb75316c07d71332fe6c3 Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Thu, 16 Nov 2017 21:45:18 +0000 Subject: Make WideString::{Format|FormatV} static This CL moves the Format and FormatV methods from WideString to be static. Bug: pdfium:934 Change-Id: I9941d6a2a5bbf0a82087cd0ea5d0f8fc42eecd3e Reviewed-on: https://pdfium-review.googlesource.com/18630 Reviewed-by: Tom Sepez Commit-Queue: dsinclair --- core/fxcrt/widestring_unittest.cpp | 85 ++++++-------------------------------- 1 file changed, 13 insertions(+), 72 deletions(-) (limited to 'core/fxcrt/widestring_unittest.cpp') diff --git a/core/fxcrt/widestring_unittest.cpp b/core/fxcrt/widestring_unittest.cpp index 42819b3349..aaa6d9cae7 100644 --- a/core/fxcrt/widestring_unittest.cpp +++ b/core/fxcrt/widestring_unittest.cpp @@ -1278,84 +1278,25 @@ TEST(WideStringView, TrimmedRight) { } TEST(WideString, FormatWidth) { - { - WideString str; - str.Format(L"%5d", 1); - EXPECT_EQ(L" 1", str); - } - - { - WideString str; - str.Format(L"%d", 1); - EXPECT_EQ(L"1", str); - } - - { - WideString str; - str.Format(L"%*d", 5, 1); - EXPECT_EQ(L" 1", str); - } - - { - WideString str; - str.Format(L"%-1d", 1); - EXPECT_EQ(L"1", str); - } - - { - WideString str; - str.Format(L"%0d", 1); - EXPECT_EQ(L"1", str); - } - - { - WideString str; - str.Format(L"%1048576d", 1); - EXPECT_EQ(L"", str); - } + EXPECT_EQ(L" 1", WideString::Format(L"%5d", 1)); + EXPECT_EQ(L"1", WideString::Format(L"%d", 1)); + EXPECT_EQ(L" 1", WideString::Format(L"%*d", 5, 1)); + EXPECT_EQ(L"1", WideString::Format(L"%-1d", 1)); + EXPECT_EQ(L"1", WideString::Format(L"%0d", 1)); + EXPECT_EQ(L"", WideString::Format(L"%1048576d", 1)); } TEST(WideString, FormatPrecision) { - { - WideString str; - str.Format(L"%.2f", 1.12345); - EXPECT_EQ(L"1.12", str); - } - - { - WideString str; - str.Format(L"%.*f", 3, 1.12345); - EXPECT_EQ(L"1.123", str); - } - - { - WideString str; - str.Format(L"%f", 1.12345); - EXPECT_EQ(L"1.123450", str); - } - - { - WideString str; - str.Format(L"%-1f", 1.12345); - EXPECT_EQ(L"1.123450", str); - } - - { - WideString str; - str.Format(L"%0f", 1.12345); - EXPECT_EQ(L"1.123450", str); - } - - { - WideString str; - str.Format(L"%.1048576f", 1.2); - EXPECT_EQ(L"", str); - } + EXPECT_EQ(L"1.12", WideString::Format(L"%.2f", 1.12345)); + EXPECT_EQ(L"1.123", WideString::Format(L"%.*f", 3, 1.12345)); + EXPECT_EQ(L"1.123450", WideString::Format(L"%f", 1.12345)); + EXPECT_EQ(L"1.123450", WideString::Format(L"%-1f", 1.12345)); + EXPECT_EQ(L"1.123450", WideString::Format(L"%0f", 1.12345)); + EXPECT_EQ(L"", WideString::Format(L"%.1048576f", 1.2)); } TEST(WideString, FormatOutOfRangeChar) { - WideString str; - str.Format(L"unsupported char '%c'", 0x00FF00FF); + WideString::Format(L"unsupported char '%c'", 0x00FF00FF); } TEST(WideString, Empty) { -- cgit v1.2.3