OLD | NEW |
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 <time.h> | 5 #include <time.h> |
6 | 6 |
| 7 #include "base/compiler_specific.h" |
7 #include "base/third_party/nspr/prtime.h" | 8 #include "base/third_party/nspr/prtime.h" |
8 #include "base/time.h" | 9 #include "base/time.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
10 | 11 |
11 using base::Time; | 12 using base::Time; |
12 | 13 |
13 namespace { | 14 namespace { |
14 | 15 |
15 // time_t representation of 15th Oct 2007 12:45:00 PDT | 16 // time_t representation of 15th Oct 2007 12:45:00 PDT |
16 PRTime comparison_time_pdt = 1192477500 * Time::kMicrosecondsPerSecond; | 17 PRTime comparison_time_pdt = 1192477500 * Time::kMicrosecondsPerSecond; |
17 | 18 |
18 // Specialized test fixture allowing time strings without timezones to be | 19 // Specialized test fixture allowing time strings without timezones to be |
19 // tested by comparing them to a known time in the local zone. | 20 // tested by comparing them to a known time in the local zone. |
20 class PRTimeTest : public testing::Test { | 21 class PRTimeTest : public testing::Test { |
21 protected: | 22 protected: |
22 virtual void SetUp() { | 23 virtual void SetUp() OVERRIDE { |
23 // Use mktime to get a time_t, and turn it into a PRTime by converting | 24 // Use mktime to get a time_t, and turn it into a PRTime by converting |
24 // seconds to microseconds. Use 15th Oct 2007 12:45:00 local. This | 25 // seconds to microseconds. Use 15th Oct 2007 12:45:00 local. This |
25 // must be a time guaranteed to be outside of a DST fallback hour in | 26 // must be a time guaranteed to be outside of a DST fallback hour in |
26 // any timezone. | 27 // any timezone. |
27 struct tm local_comparison_tm = { | 28 struct tm local_comparison_tm = { |
28 0, // second | 29 0, // second |
29 45, // minute | 30 45, // minute |
30 12, // hour | 31 12, // hour |
31 15, // day of month | 32 15, // day of month |
32 10 - 1, // month | 33 10 - 1, // month |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 | 156 |
156 TEST_F(PRTimeTest, ParseTimeTestNotNormalized2) { | 157 TEST_F(PRTimeTest, ParseTimeTestNotNormalized2) { |
157 PRTime parsed_time = 0; | 158 PRTime parsed_time = 0; |
158 PRStatus result = PR_ParseTimeString("Sun Oct 14 36:45 PDT 2007", | 159 PRStatus result = PR_ParseTimeString("Sun Oct 14 36:45 PDT 2007", |
159 PR_FALSE, &parsed_time); | 160 PR_FALSE, &parsed_time); |
160 EXPECT_EQ(PR_SUCCESS, result); | 161 EXPECT_EQ(PR_SUCCESS, result); |
161 EXPECT_EQ(comparison_time_pdt, parsed_time); | 162 EXPECT_EQ(comparison_time_pdt, parsed_time); |
162 } | 163 } |
163 | 164 |
164 } // namespace | 165 } // namespace |
OLD | NEW |