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

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

Issue 1852433005: Convert //base to use std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase after r384946 Created 4 years, 8 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 | « base/i18n/time_formatting.cc ('k') | base/i18n/timezone.cc » ('j') | 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 <memory>
8
7 #include "base/i18n/rtl.h" 9 #include "base/i18n/rtl.h"
8 #include "base/memory/scoped_ptr.h"
9 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
10 #include "base/test/icu_test_util.h" 11 #include "base/test/icu_test_util.h"
11 #include "base/time/time.h" 12 #include "base/time/time.h"
12 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
13 #include "third_party/icu/source/common/unicode/uversion.h" 14 #include "third_party/icu/source/common/unicode/uversion.h"
14 #include "third_party/icu/source/i18n/unicode/calendar.h" 15 #include "third_party/icu/source/i18n/unicode/calendar.h"
15 #include "third_party/icu/source/i18n/unicode/timezone.h" 16 #include "third_party/icu/source/i18n/unicode/timezone.h"
16 #include "third_party/icu/source/i18n/unicode/tzfmt.h" 17 #include "third_party/icu/source/i18n/unicode/tzfmt.h"
17 18
18 namespace base { 19 namespace base {
19 namespace { 20 namespace {
20 21
21 const Time::Exploded kTestDateTimeExploded = { 22 const Time::Exploded kTestDateTimeExploded = {
22 2011, 4, 6, 30, // Sat, Apr 30, 2011 23 2011, 4, 6, 30, // Sat, Apr 30, 2011
23 15, 42, 7, 0 // 15:42:07.000 24 15, 42, 7, 0 // 15:42:07.000
24 }; 25 };
25 26
26 // Returns difference between the local time and GMT formatted as string. 27 // Returns difference between the local time and GMT formatted as string.
27 // This function gets |time| because the difference depends on time, 28 // This function gets |time| because the difference depends on time,
28 // see https://en.wikipedia.org/wiki/Daylight_saving_time for details. 29 // see https://en.wikipedia.org/wiki/Daylight_saving_time for details.
29 base::string16 GetShortTimeZone(const Time& time) { 30 base::string16 GetShortTimeZone(const Time& time) {
30 UErrorCode status = U_ZERO_ERROR; 31 UErrorCode status = U_ZERO_ERROR;
31 scoped_ptr<icu::TimeZone> zone(icu::TimeZone::createDefault()); 32 std::unique_ptr<icu::TimeZone> zone(icu::TimeZone::createDefault());
32 scoped_ptr<icu::TimeZoneFormat> zone_formatter( 33 std::unique_ptr<icu::TimeZoneFormat> zone_formatter(
33 icu::TimeZoneFormat::createInstance(icu::Locale::getDefault(), status)); 34 icu::TimeZoneFormat::createInstance(icu::Locale::getDefault(), status));
34 EXPECT_TRUE(U_SUCCESS(status)); 35 EXPECT_TRUE(U_SUCCESS(status));
35 icu::UnicodeString name; 36 icu::UnicodeString name;
36 zone_formatter->format(UTZFMT_STYLE_SPECIFIC_SHORT, *zone, 37 zone_formatter->format(UTZFMT_STYLE_SPECIFIC_SHORT, *zone,
37 static_cast<UDate>(time.ToDoubleT() * 1000), 38 static_cast<UDate>(time.ToDoubleT() * 1000),
38 name, nullptr); 39 name, nullptr);
39 return base::string16(name.getBuffer(), name.length()); 40 return base::string16(name.getBuffer(), name.length());
40 } 41 }
41 42
42 #if defined(OS_ANDROID) 43 #if defined(OS_ANDROID)
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 EXPECT_EQ(ASCIIToUTF16("30/04/2011, 15:42:07 ") + GetShortTimeZone(time), 211 EXPECT_EQ(ASCIIToUTF16("30/04/2011, 15:42:07 ") + GetShortTimeZone(time),
211 TimeFormatShortDateAndTimeWithTimeZone(time)); 212 TimeFormatShortDateAndTimeWithTimeZone(time));
212 EXPECT_EQ(ASCIIToUTF16("Saturday, 30 April 2011 at 15:42:07"), 213 EXPECT_EQ(ASCIIToUTF16("Saturday, 30 April 2011 at 15:42:07"),
213 TimeFormatFriendlyDateAndTime(time)); 214 TimeFormatFriendlyDateAndTime(time));
214 EXPECT_EQ(ASCIIToUTF16("Saturday, 30 April 2011"), 215 EXPECT_EQ(ASCIIToUTF16("Saturday, 30 April 2011"),
215 TimeFormatFriendlyDate(time)); 216 TimeFormatFriendlyDate(time));
216 } 217 }
217 218
218 } // namespace 219 } // namespace
219 } // namespace base 220 } // namespace base
OLDNEW
« no previous file with comments | « base/i18n/time_formatting.cc ('k') | base/i18n/timezone.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698