Index: chrome/common/time_format_unittest.cc |
diff --git a/chrome/common/time_format_unittest.cc b/chrome/common/time_format_unittest.cc |
index 31976e3bd40838f24bf9f31e7429f12b64f3b351..ddd5e426a1a284d97f15ed79af173fe846845ca6 100644 |
--- a/chrome/common/time_format_unittest.cc |
+++ b/chrome/common/time_format_unittest.cc |
@@ -2,9 +2,11 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
+#include <locale.h> |
#include <time.h> |
#include "base/basictypes.h" |
+#include "base/logging.h" |
#include "base/string16.h" |
#include "base/time.h" |
#include "base/utf_string_conversions.h" |
@@ -69,3 +71,29 @@ TEST(TimeFormat, FormatTime) { |
TestTimeFormats(three_days, "3 days"); |
TestTimeFormats(three_days + four_hours, "3 days"); |
} |
+ |
+TEST(TimeFormat, FAILS_DecimalPointNotDot) { |
+ // Some locales use a comma ',' instead of a dot '.' as the separator for |
+ // decimal digits. The icu library wasn't handling this, leading to "1" |
+ // being internally converted to "+1,0e00" and ultimately leading to "NaN". |
+ // This showed up on the browser on estimated download time, for example. |
+ // http://crbug.com/60476 |
+ |
+ const char *locales[] = { "fr_FR", "fr_FR.utf8", "fr_FR.UTF-8" }; |
+ const char *locale; |
+ for (uint32 i = 0; i < arraysize(locales); ++i) { |
+ locale = setlocale(LC_ALL, locales[i]); |
Paweł Hajdan Jr.
2011/05/11 14:47:13
And now all following tests run with the changed l
Joao da Silva
2011/05/11 15:35:07
Yikes, true. Fixed by adding a ScopedChangeLocale.
|
+ if (locale != NULL) |
+ break; |
+ } |
+ |
+ if (locale == NULL) { |
+ LOG(WARNING) << "Skipping test because machine doesn't have the fr_FR " |
+ << "locale installed."; |
+ return; |
+ } |
+ |
+ string16 one_min = TimeFormat::TimeRemainingShort(TimeDelta::FromMinutes(1)); |
+ EXPECT_EQ(ASCIIToUTF16("1 min"), one_min) << "fr_FR locale generates " |
+ << one_min; |
+} |