diff options
author | avi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-22 20:40:22 +0000 |
---|---|---|
committer | avi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-22 20:40:22 +0000 |
commit | 7a3b263af6356885628add7a8843a40dbee5b8ab (patch) | |
tree | eff6140c44d29b6904b90366df65161364ea555f /base/string_util_unittest.cc | |
parent | efaba4815ff6786082583393ad06f8c22ef11fa0 (diff) | |
download | chromium_src-7a3b263af6356885628add7a8843a40dbee5b8ab.zip chromium_src-7a3b263af6356885628add7a8843a40dbee5b8ab.tar.gz chromium_src-7a3b263af6356885628add7a8843a40dbee5b8ab.tar.bz2 |
Localize strings, speeds.
BUG=86527
TEST=run in non-English. For European languages, during a download the decimal separators should be commas (e.g. "0,0 MB"). (The speeds are in strings files and might take a little time to run through the translation machinery.)
Review URL: http://codereview.chromium.org/7189076
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@90092 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/string_util_unittest.cc')
-rw-r--r-- | base/string_util_unittest.cc | 68 |
1 files changed, 18 insertions, 50 deletions
diff --git a/base/string_util_unittest.cc b/base/string_util_unittest.cc index 8bdeaf5..0911aae 100644 --- a/base/string_util_unittest.cc +++ b/base/string_util_unittest.cc @@ -491,32 +491,10 @@ TEST(StringUtilTest, LowerCaseEqualsASCII) { } } -TEST(StringUtilTest, GetByteDisplayUnits) { +TEST(StringUtilTest, FormatBytesUnlocalized) { static const struct { int64 bytes; - DataUnits expected; - } cases[] = { - {0, DATA_UNITS_BYTE}, - {512, DATA_UNITS_BYTE}, - {10*1024, DATA_UNITS_KIBIBYTE}, - {10*1024*1024, DATA_UNITS_MEBIBYTE}, - {10LL*1024*1024*1024, DATA_UNITS_GIBIBYTE}, - {~(1LL<<63), DATA_UNITS_GIBIBYTE}, -#ifdef NDEBUG - {-1, DATA_UNITS_BYTE}, -#endif - }; - - for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) - EXPECT_EQ(cases[i].expected, GetByteDisplayUnits(cases[i].bytes)); -} - -TEST(StringUtilTest, FormatBytes) { - static const struct { - int64 bytes; - DataUnits 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 @@ -524,39 +502,29 @@ 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, "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, - "105", "105 GB"}, - {~(1LL<<63), DATA_UNITS_GIBIBYTE, "8589934592", "8589934592 GB"}, - - {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, - "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, "", ""}, -#endif + {0, "0 B"}, + {512, "512 B"}, + {1024*1024, "1.0 MB"}, + {1024*1024*1024, "1.0 GB"}, + {10LL*1024*1024*1024, "10.0 GB"}, + {99LL*1024*1024*1024, "99.0 GB"}, + {105LL*1024*1024*1024, "105 GB"}, + {105LL*1024*1024*1024 + 500LL*1024*1024, "105 GB"}, + {~(1LL<<63), "8192 PB"}, + + {99*1024 + 103, "99.1 kB"}, + {1024*1024 + 103, "1.0 MB"}, + {1024*1024 + 205 * 1024, "1.2 MB"}, + {1024*1024*1024 + (927 * 1024*1024), "1.9 GB"}, + {10LL*1024*1024*1024, "10.0 GB"}, + {100LL*1024*1024*1024, "100 GB"}, }; for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) { EXPECT_EQ(ASCIIToUTF16(cases[i].expected), - FormatBytes(cases[i].bytes, cases[i].units, false)); - EXPECT_EQ(ASCIIToUTF16(cases[i].expected_with_units), - FormatBytes(cases[i].bytes, cases[i].units, true)); + FormatBytesUnlocalized(cases[i].bytes)); } } - TEST(StringUtilTest, ReplaceSubstringsAfterOffset) { static const struct { const char* str; |