OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "crypto/nss_util.h" | |
6 | |
7 #include <prtime.h> | |
8 | |
9 #include "base/time.h" | |
10 #include "testing/gtest/include/gtest/gtest.h" | |
11 | |
12 namespace crypto { | |
13 | |
14 TEST(NSSUtilTest, PRTimeConversion) { | |
15 EXPECT_EQ(base::Time::UnixEpoch(), PRTimeToBaseTime(0)); | |
16 EXPECT_EQ(0, BaseTimeToPRTime(base::Time::UnixEpoch())); | |
17 | |
18 PRExplodedTime prxtime; | |
19 prxtime.tm_params.tp_gmt_offset = 0; | |
20 prxtime.tm_params.tp_dst_offset = 0; | |
21 base::Time::Exploded exploded; | |
22 prxtime.tm_year = exploded.year = 2011; | |
23 exploded.month = 12; | |
24 prxtime.tm_month = 11; | |
25 prxtime.tm_wday = exploded.day_of_week = 0; // Should be unusued. | |
26 prxtime.tm_mday = exploded.day_of_month = 10; | |
27 prxtime.tm_hour = exploded.hour = 2; | |
28 prxtime.tm_min = exploded.minute = 52; | |
29 prxtime.tm_sec = exploded.second = 19; | |
30 exploded.millisecond = 342; | |
31 prxtime.tm_usec = 342000; | |
32 | |
33 EXPECT_EQ(base::Time::FromUTCExploded(exploded), | |
34 PRTimeToBaseTime(PR_ImplodeTime(&prxtime))); | |
35 EXPECT_EQ(PR_ImplodeTime(&prxtime), | |
36 BaseTimeToPRTime(base::Time::FromUTCExploded(exploded))); | |
wtc
2011/12/13 00:06:08
Nit: save PR_ImplodeTime(&prxtime) and base::Time:
| |
37 } | |
38 | |
39 } // namespace crypto | |
OLD | NEW |