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

Side by Side Diff: crypto/nss_util_unittest.cc

Issue 659943004: Type conversion fixes, crypto/ edition. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: I am dumb Created 6 years, 2 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 | « crypto/ec_private_key_nss.cc ('k') | crypto/signature_verifier_unittest.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 "crypto/nss_util.h" 5 #include "crypto/nss_util.h"
6 6
7 #include <prtime.h> 7 #include <prtime.h>
8 8
9 #include "base/time/time.h" 9 #include "base/time/time.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
11 11
12 namespace crypto { 12 namespace crypto {
13 13
14 TEST(NSSUtilTest, PRTimeConversion) { 14 TEST(NSSUtilTest, PRTimeConversion) {
15 EXPECT_EQ(base::Time::UnixEpoch(), PRTimeToBaseTime(0)); 15 EXPECT_EQ(base::Time::UnixEpoch(), PRTimeToBaseTime(0));
16 EXPECT_EQ(0, BaseTimeToPRTime(base::Time::UnixEpoch())); 16 EXPECT_EQ(0, BaseTimeToPRTime(base::Time::UnixEpoch()));
17 17
18 PRExplodedTime prxtime; 18 PRExplodedTime prxtime;
19 prxtime.tm_params.tp_gmt_offset = 0; 19 prxtime.tm_params.tp_gmt_offset = 0;
20 prxtime.tm_params.tp_dst_offset = 0; 20 prxtime.tm_params.tp_dst_offset = 0;
21 base::Time::Exploded exploded; 21 base::Time::Exploded exploded;
22 prxtime.tm_year = exploded.year = 2011; 22 exploded.year = prxtime.tm_year = 2011;
Peter Kasting 2014/10/16 23:25:55 Note that the ordering changes here aren't just co
wtc 2014/10/21 02:08:50 It might be good to add this comment to the source
Peter Kasting 2014/10/21 02:20:13 Done.
23 exploded.month = 12; 23 exploded.month = 12;
24 prxtime.tm_month = 11; 24 prxtime.tm_month = 11;
25 prxtime.tm_wday = exploded.day_of_week = 0; // Should be unusued. 25 exploded.day_of_week = prxtime.tm_wday = 0; // Should be unused.
26 prxtime.tm_mday = exploded.day_of_month = 10; 26 exploded.day_of_month = prxtime.tm_mday = 10;
27 prxtime.tm_hour = exploded.hour = 2; 27 exploded.hour = prxtime.tm_hour = 2;
28 prxtime.tm_min = exploded.minute = 52; 28 exploded.minute = prxtime.tm_min = 52;
29 prxtime.tm_sec = exploded.second = 19; 29 exploded.second = prxtime.tm_sec = 19;
30 exploded.millisecond = 342; 30 exploded.millisecond = 342;
31 prxtime.tm_usec = 342000; 31 prxtime.tm_usec = 342000;
32 32
33 PRTime pr_time = PR_ImplodeTime(&prxtime); 33 PRTime pr_time = PR_ImplodeTime(&prxtime);
34 base::Time base_time = base::Time::FromUTCExploded(exploded); 34 base::Time base_time = base::Time::FromUTCExploded(exploded);
35 35
36 EXPECT_EQ(base_time, PRTimeToBaseTime(pr_time)); 36 EXPECT_EQ(base_time, PRTimeToBaseTime(pr_time));
37 EXPECT_EQ(pr_time, BaseTimeToPRTime(base_time)); 37 EXPECT_EQ(pr_time, BaseTimeToPRTime(base_time));
38 } 38 }
39 39
40 } // namespace crypto 40 } // namespace crypto
OLDNEW
« no previous file with comments | « crypto/ec_private_key_nss.cc ('k') | crypto/signature_verifier_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698