diff options
author | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-18 21:30:36 +0000 |
---|---|---|
committer | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-18 21:30:36 +0000 |
commit | 016d78de3eb0ee784728c99836cb42753e8dea60 (patch) | |
tree | 398679128dd10491063194548ae93fb3115fad19 /base/string_util_unittest.cc | |
parent | 7b0ac2b15ccf3652097cb87d60f34f6bfda6388a (diff) | |
download | chromium_src-016d78de3eb0ee784728c99836cb42753e8dea60.zip chromium_src-016d78de3eb0ee784728c99836cb42753e8dea60.tar.gz chromium_src-016d78de3eb0ee784728c99836cb42753e8dea60.tar.bz2 |
Convert FormatBytes to string16.
I considered ASCII, but it's producing what is intended to be a
human-readable string. For example, in theory the "bytes/s" annotation
could be localized into a language where the "b" is non-ASCII.
Review URL: http://codereview.chromium.org/3107021
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@56603 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/string_util_unittest.cc')
-rw-r--r-- | base/string_util_unittest.cc | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/base/string_util_unittest.cc b/base/string_util_unittest.cc index 9f72b1f..8a8fc39 100644 --- a/base/string_util_unittest.cc +++ b/base/string_util_unittest.cc @@ -530,8 +530,8 @@ TEST(StringUtilTest, FormatBytes) { static const struct { int64 bytes; DataUnits units; - const wchar_t* expected; - const wchar_t* expected_with_units; + const char* expected; + const char* expected_with_units; } cases[] = { // Expected behavior: we show one post-decimal digit when we have // under two pre-decimal digits, except in cases where it makes no @@ -539,35 +539,35 @@ TEST(StringUtilTest, FormatBytes) { // Since we switch units once we cross the 1000 mark, this keeps // the display of file sizes or bytes consistently around three // digits. - {0, DATA_UNITS_BYTE, L"0", L"0 B"}, - {512, DATA_UNITS_BYTE, L"512", L"512 B"}, - {512, DATA_UNITS_KIBIBYTE, L"0.5", L"0.5 kB"}, - {1024*1024, DATA_UNITS_KIBIBYTE, L"1024", L"1024 kB"}, - {1024*1024, DATA_UNITS_MEBIBYTE, L"1.0", L"1.0 MB"}, - {1024*1024*1024, DATA_UNITS_GIBIBYTE, L"1.0", L"1.0 GB"}, - {10LL*1024*1024*1024, DATA_UNITS_GIBIBYTE, L"10.0", L"10.0 GB"}, - {99LL*1024*1024*1024, DATA_UNITS_GIBIBYTE, L"99.0", L"99.0 GB"}, - {105LL*1024*1024*1024, DATA_UNITS_GIBIBYTE, L"105", L"105 GB"}, + {0, DATA_UNITS_BYTE, "0", "0 B"}, + {512, DATA_UNITS_BYTE, "512", "512 B"}, + {512, DATA_UNITS_KIBIBYTE, "0.5", "0.5 kB"}, + {1024*1024, DATA_UNITS_KIBIBYTE, "1024", "1024 kB"}, + {1024*1024, DATA_UNITS_MEBIBYTE, "1.0", "1.0 MB"}, + {1024*1024*1024, DATA_UNITS_GIBIBYTE, "1.0", "1.0 GB"}, + {10LL*1024*1024*1024, DATA_UNITS_GIBIBYTE, "10.0", "10.0 GB"}, + {99LL*1024*1024*1024, DATA_UNITS_GIBIBYTE, "99.0", "99.0 GB"}, + {105LL*1024*1024*1024, DATA_UNITS_GIBIBYTE, "105", "105 GB"}, {105LL*1024*1024*1024 + 500LL*1024*1024, DATA_UNITS_GIBIBYTE, - L"105", L"105 GB"}, - {~(1LL<<63), DATA_UNITS_GIBIBYTE, L"8589934592", L"8589934592 GB"}, + "105", "105 GB"}, + {~(1LL<<63), DATA_UNITS_GIBIBYTE, "8589934592", "8589934592 GB"}, - {99*1024 + 103, DATA_UNITS_KIBIBYTE, L"99.1", L"99.1 kB"}, - {1024*1024 + 103, DATA_UNITS_KIBIBYTE, L"1024", L"1024 kB"}, - {1024*1024 + 205 * 1024, DATA_UNITS_MEBIBYTE, L"1.2", L"1.2 MB"}, + {99*1024 + 103, DATA_UNITS_KIBIBYTE, "99.1", "99.1 kB"}, + {1024*1024 + 103, DATA_UNITS_KIBIBYTE, "1024", "1024 kB"}, + {1024*1024 + 205 * 1024, DATA_UNITS_MEBIBYTE, "1.2", "1.2 MB"}, {1024*1024*1024 + (927 * 1024*1024), DATA_UNITS_GIBIBYTE, - L"1.9", L"1.9 GB"}, - {10LL*1024*1024*1024, DATA_UNITS_GIBIBYTE, L"10.0", L"10.0 GB"}, - {100LL*1024*1024*1024, DATA_UNITS_GIBIBYTE, L"100", L"100 GB"}, + "1.9", "1.9 GB"}, + {10LL*1024*1024*1024, DATA_UNITS_GIBIBYTE, "10.0", "10.0 GB"}, + {100LL*1024*1024*1024, DATA_UNITS_GIBIBYTE, "100", "100 GB"}, #ifdef NDEBUG - {-1, DATA_UNITS_BYTE, L"", L""}, + {-1, DATA_UNITS_BYTE, "", ""}, #endif }; for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) { - EXPECT_EQ(cases[i].expected, + EXPECT_EQ(ASCIIToUTF16(cases[i].expected), FormatBytes(cases[i].bytes, cases[i].units, false)); - EXPECT_EQ(cases[i].expected_with_units, + EXPECT_EQ(ASCIIToUTF16(cases[i].expected_with_units), FormatBytes(cases[i].bytes, cases[i].units, true)); } } |