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

Side by Side Diff: base/i18n/time_formatting_unittest.cc

Issue 911453002: Fix Valgrind error in earlier time_formatting_unittest.cc change. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Created 5 years, 10 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
« 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "base/i18n/time_formatting.h" 5 #include "base/i18n/time_formatting.h"
6 6
7 #include "base/i18n/rtl.h" 7 #include "base/i18n/rtl.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "base/time/time.h" 10 #include "base/time/time.h"
11 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
12 #include "third_party/icu/source/common/unicode/uversion.h" 12 #include "third_party/icu/source/common/unicode/uversion.h"
13 #include "third_party/icu/source/i18n/unicode/calendar.h" 13 #include "third_party/icu/source/i18n/unicode/calendar.h"
14 #include "third_party/icu/source/i18n/unicode/timezone.h" 14 #include "third_party/icu/source/i18n/unicode/timezone.h"
15 15
16 namespace base { 16 namespace base {
17 namespace { 17 namespace {
18 18
19 const Time::Exploded kTestDateTimeExploded = { 19 const Time::Exploded kTestDateTimeExploded = {
20 2011, 4, 6, 30, // Sat, Apr 30, 2011 20 2011, 4, 6, 30, // Sat, Apr 30, 2011
21 15, 42, 7, 0 // 15:42:07.000 21 15, 42, 7, 0 // 15:42:07.000
22 }; 22 };
23 23
24 base::string16 GetShortTimeZone() { 24 base::string16 GetShortTimeZone() {
25 scoped_ptr<icu::TimeZone> zone(icu::TimeZone::createDefault()); 25 scoped_ptr<icu::TimeZone> zone(icu::TimeZone::createDefault());
26 // This code shamelessly taken from
27 // src/chrome/browser/chromeos/system/timezone_util.cc.
28 int raw_offset, dst_offset;
29 UErrorCode status;
30 zone->getOffset(icu::Calendar::getNow(), false, raw_offset, dst_offset,
31 status);
32 icu::UnicodeString name; 26 icu::UnicodeString name;
33 zone->getDisplayName(true, icu::TimeZone::SHORT, name); 27 zone->getDisplayName(true, icu::TimeZone::SHORT, name);
34 return base::string16(name.getBuffer(), name.length()); 28 return base::string16(name.getBuffer(), name.length());
35 } 29 }
36 30
37 TEST(TimeFormattingTest, TimeFormatTimeOfDayDefault12h) { 31 TEST(TimeFormattingTest, TimeFormatTimeOfDayDefault12h) {
38 // Test for a locale defaulted to 12h clock. 32 // Test for a locale defaulted to 12h clock.
39 // As an instance, we use third_party/icu/source/data/locales/en.txt. 33 // As an instance, we use third_party/icu/source/data/locales/en.txt.
40 i18n::SetICUDefaultLocale("en_US"); 34 i18n::SetICUDefaultLocale("en_US");
41 35
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 EXPECT_EQ(ASCIIToUTF16("30/04/2011 15:42:07 ") + GetShortTimeZone(), 163 EXPECT_EQ(ASCIIToUTF16("30/04/2011 15:42:07 ") + GetShortTimeZone(),
170 TimeFormatShortDateAndTimeWithTimeZone(time)); 164 TimeFormatShortDateAndTimeWithTimeZone(time));
171 EXPECT_EQ(ASCIIToUTF16("Saturday, 30 April 2011 15:42:07"), 165 EXPECT_EQ(ASCIIToUTF16("Saturday, 30 April 2011 15:42:07"),
172 TimeFormatFriendlyDateAndTime(time)); 166 TimeFormatFriendlyDateAndTime(time));
173 EXPECT_EQ(ASCIIToUTF16("Saturday, 30 April 2011"), 167 EXPECT_EQ(ASCIIToUTF16("Saturday, 30 April 2011"),
174 TimeFormatFriendlyDate(time)); 168 TimeFormatFriendlyDate(time));
175 } 169 }
176 170
177 } // namespace 171 } // namespace
178 } // namespace base 172 } // namespace base
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