diff options
author | mattm@chromium.org <mattm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-15 20:37:28 +0000 |
---|---|---|
committer | mattm@chromium.org <mattm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-15 20:37:28 +0000 |
commit | ca929ed34121d8f90788f16dfd1fe555bb5701ae (patch) | |
tree | d4aedc59332c18e21c2368f9006fa92e1bf44b65 /crypto/nss_util_unittest.cc | |
parent | b95b08d0da727df948ecbd8d3bebe4ecb09b97d5 (diff) | |
download | chromium_src-ca929ed34121d8f90788f16dfd1fe555bb5701ae.zip chromium_src-ca929ed34121d8f90788f16dfd1fe555bb5701ae.tar.gz chromium_src-ca929ed34121d8f90788f16dfd1fe555bb5701ae.tar.bz2 |
Reland: Simplify PRTimeToBaseTime implementation, add BaseTimeToPRTime.
BUG=107047
TEST=crypto_unittests
TBR=wtc@chromium.org
Review URL: http://codereview.chromium.org/8956003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@114693 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'crypto/nss_util_unittest.cc')
-rw-r--r-- | crypto/nss_util_unittest.cc | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/crypto/nss_util_unittest.cc b/crypto/nss_util_unittest.cc new file mode 100644 index 0000000..cc24b61 --- /dev/null +++ b/crypto/nss_util_unittest.cc @@ -0,0 +1,40 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "crypto/nss_util.h" + +#include <prtime.h> + +#include "base/time.h" +#include "testing/gtest/include/gtest/gtest.h" + +namespace crypto { + +TEST(NSSUtilTest, PRTimeConversion) { + EXPECT_EQ(base::Time::UnixEpoch(), PRTimeToBaseTime(0)); + EXPECT_EQ(0, BaseTimeToPRTime(base::Time::UnixEpoch())); + + PRExplodedTime prxtime; + prxtime.tm_params.tp_gmt_offset = 0; + prxtime.tm_params.tp_dst_offset = 0; + base::Time::Exploded exploded; + prxtime.tm_year = exploded.year = 2011; + exploded.month = 12; + prxtime.tm_month = 11; + prxtime.tm_wday = exploded.day_of_week = 0; // Should be unusued. + prxtime.tm_mday = exploded.day_of_month = 10; + prxtime.tm_hour = exploded.hour = 2; + prxtime.tm_min = exploded.minute = 52; + prxtime.tm_sec = exploded.second = 19; + exploded.millisecond = 342; + prxtime.tm_usec = 342000; + + PRTime pr_time = PR_ImplodeTime(&prxtime); + base::Time base_time = base::Time::FromUTCExploded(exploded); + + EXPECT_EQ(base_time, PRTimeToBaseTime(pr_time)); + EXPECT_EQ(pr_time, BaseTimeToPRTime(base_time)); +} + +} // namespace crypto |