Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(211)

Side by Side Diff: chrome/common/time_format_unittest.cc

Issue 7003028: Added a test checking for TimeFormat:: producing NaN, rolled icu version (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <locale.h>
5 #include <time.h> 6 #include <time.h>
6 7
7 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/logging.h"
8 #include "base/string16.h" 10 #include "base/string16.h"
9 #include "base/time.h" 11 #include "base/time.h"
10 #include "base/utf_string_conversions.h" 12 #include "base/utf_string_conversions.h"
11 #include "chrome/common/time_format.h" 13 #include "chrome/common/time_format.h"
12 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
13 15
14 using base::Time; 16 using base::Time;
15 using base::TimeDelta; 17 using base::TimeDelta;
16 18
17 TEST(TimeFormat, RelativeDate) { 19 TEST(TimeFormat, RelativeDate) {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 TestTimeFormats(one_sec + twohundred_millisecs, "1 sec"); 64 TestTimeFormats(one_sec + twohundred_millisecs, "1 sec");
63 TestTimeFormats(five_secs + twohundred_millisecs, "5 secs"); 65 TestTimeFormats(five_secs + twohundred_millisecs, "5 secs");
64 TestTimeFormats(one_min + five_secs, "1 min"); 66 TestTimeFormats(one_min + five_secs, "1 min");
65 TestTimeFormats(three_mins + twohundred_millisecs, "3 mins"); 67 TestTimeFormats(three_mins + twohundred_millisecs, "3 mins");
66 TestTimeFormats(one_hour + five_secs, "1 hour"); 68 TestTimeFormats(one_hour + five_secs, "1 hour");
67 TestTimeFormats(four_hours + five_secs, "4 hours"); 69 TestTimeFormats(four_hours + five_secs, "4 hours");
68 TestTimeFormats(one_day + five_secs, "1 day"); 70 TestTimeFormats(one_day + five_secs, "1 day");
69 TestTimeFormats(three_days, "3 days"); 71 TestTimeFormats(three_days, "3 days");
70 TestTimeFormats(three_days + four_hours, "3 days"); 72 TestTimeFormats(three_days + four_hours, "3 days");
71 } 73 }
74
75 TEST(TimeFormat, FAILS_DecimalPointNotDot) {
76 // Some locales use a comma ',' instead of a dot '.' as the separator for
77 // decimal digits. The icu library wasn't handling this, leading to "1"
78 // being internally converted to "+1,0e00" and ultimately leading to "NaN".
79 // This showed up on the browser on estimated download time, for example.
80 // http://crbug.com/60476
81
82 const char *locales[] = { "fr_FR", "fr_FR.utf8", "fr_FR.UTF-8" };
83 const char *locale;
84 for (uint32 i = 0; i < arraysize(locales); ++i) {
85 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.
86 if (locale != NULL)
87 break;
88 }
89
90 if (locale == NULL) {
91 LOG(WARNING) << "Skipping test because machine doesn't have the fr_FR "
92 << "locale installed.";
93 return;
94 }
95
96 string16 one_min = TimeFormat::TimeRemainingShort(TimeDelta::FromMinutes(1));
97 EXPECT_EQ(ASCIIToUTF16("1 min"), one_min) << "fr_FR locale generates "
98 << one_min;
99 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698