1 // Copyright 2011 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "crypto/nss_util.h"
9 #include "base/time/time.h"
10 #include "testing/gtest/include/gtest/gtest.h"
14 TEST(NSSUtilTest, PRTimeConversion) {
15 EXPECT_EQ(base::Time::UnixEpoch(), PRTimeToBaseTime(0));
16 EXPECT_EQ(0, BaseTimeToPRTime(base::Time::UnixEpoch()));
18 static constexpr PRExplodedTime kPrxtime = {
24 .tm_month = 11, // 0-based
26 .tm_params = {.tp_gmt_offset = 0, .tp_dst_offset = 0}};
27 PRTime pr_time = PR_ImplodeTime(&kPrxtime);
29 static constexpr base::Time::Exploded kExploded = {.year = 2011,
30 .month = 12, // 1-based
37 EXPECT_TRUE(base::Time::FromUTCExploded(kExploded, &base_time));
39 EXPECT_EQ(base_time, PRTimeToBaseTime(pr_time));
40 EXPECT_EQ(pr_time, BaseTimeToPRTime(base_time));