summaryrefslogtreecommitdiffstats
path: root/base/pr_time_unittest.cc
diff options
context:
space:
mode:
authorshinyak@google.com <shinyak@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-26 18:17:03 +0000
committershinyak@google.com <shinyak@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-26 18:17:03 +0000
commit5086cfc86ff0050abbf63972bd70cbc48d5e7f57 (patch)
tree98855082b195a1a0648475a57d7ba3778ff14f20 /base/pr_time_unittest.cc
parenta60865a91102be0b19d826fb9d26f0bc98066ca6 (diff)
downloadchromium_src-5086cfc86ff0050abbf63972bd70cbc48d5e7f57.zip
chromium_src-5086cfc86ff0050abbf63972bd70cbc48d5e7f57.tar.gz
chromium_src-5086cfc86ff0050abbf63972bd70cbc48d5e7f57.tar.bz2
Removed wchar_t from Time::FromString.
Also, some of the test case are moved from pr_time_unittests to time_unittests. BUG=77962 TEST=base_unittests:TimeTest.* Review URL: http://codereview.chromium.org/6903022 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@83048 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/pr_time_unittest.cc')
-rw-r--r--base/pr_time_unittest.cc146
1 files changed, 1 insertions, 145 deletions
diff --git a/base/pr_time_unittest.cc b/base/pr_time_unittest.cc
index 646eb16..12521a4 100644
--- a/base/pr_time_unittest.cc
+++ b/base/pr_time_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// 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.
@@ -132,149 +132,5 @@ TEST_F(PRTimeTest, ParseTimeTest9) {
EXPECT_EQ(parsed_time, comparison_time_pdt);
}
-// This tests the Time::FromString wrapper over PR_ParseTimeString
-TEST_F(PRTimeTest, ParseTimeTest10) {
- Time parsed_time;
- bool result = Time::FromString(L"15/10/07 12:45", &parsed_time);
- EXPECT_TRUE(result);
-
- time_t computed_time = parsed_time.ToTimeT();
- time_t time_to_compare = comparison_time_local_ /
- Time::kMicrosecondsPerSecond;
- EXPECT_EQ(computed_time, time_to_compare);
-}
-
-// This tests the Time::FromString wrapper over PR_ParseTimeString
-TEST_F(PRTimeTest, ParseTimeTest11) {
- Time parsed_time;
- bool result = Time::FromString(L"Mon, 15 Oct 2007 19:45:00 GMT",
- &parsed_time);
- EXPECT_TRUE(result);
-
- time_t computed_time = parsed_time.ToTimeT();
- time_t time_to_compare = comparison_time_pdt / Time::kMicrosecondsPerSecond;
- EXPECT_EQ(computed_time, time_to_compare);
-}
-
-// Test some of edge cases around epoch, etc.
-TEST_F(PRTimeTest, ParseTimeTestEpoch0) {
- Time parsed_time;
-
- // time_t == epoch == 0
- EXPECT_TRUE(Time::FromString(L"Thu Jan 01 01:00:00 +0100 1970",
- &parsed_time));
- EXPECT_EQ(0, parsed_time.ToTimeT());
- EXPECT_TRUE(Time::FromString(L"Thu Jan 01 00:00:00 GMT 1970",
- &parsed_time));
- EXPECT_EQ(0, parsed_time.ToTimeT());
-}
-
-TEST_F(PRTimeTest, ParseTimeTestEpoch1) {
- Time parsed_time;
-
- // time_t == 1 second after epoch == 1
- EXPECT_TRUE(Time::FromString(L"Thu Jan 01 01:00:01 +0100 1970",
- &parsed_time));
- EXPECT_EQ(1, parsed_time.ToTimeT());
- EXPECT_TRUE(Time::FromString(L"Thu Jan 01 00:00:01 GMT 1970",
- &parsed_time));
- EXPECT_EQ(1, parsed_time.ToTimeT());
-}
-
-TEST_F(PRTimeTest, ParseTimeTestEpoch2) {
- Time parsed_time;
-
- // time_t == 2 seconds after epoch == 2
- EXPECT_TRUE(Time::FromString(L"Thu Jan 01 01:00:02 +0100 1970",
- &parsed_time));
- EXPECT_EQ(2, parsed_time.ToTimeT());
- EXPECT_TRUE(Time::FromString(L"Thu Jan 01 00:00:02 GMT 1970",
- &parsed_time));
- EXPECT_EQ(2, parsed_time.ToTimeT());
-}
-
-TEST_F(PRTimeTest, ParseTimeTestEpochNeg1) {
- Time parsed_time;
-
- // time_t == 1 second before epoch == -1
- EXPECT_TRUE(Time::FromString(L"Thu Jan 01 00:59:59 +0100 1970",
- &parsed_time));
- EXPECT_EQ(-1, parsed_time.ToTimeT());
- EXPECT_TRUE(Time::FromString(L"Wed Dec 31 23:59:59 GMT 1969",
- &parsed_time));
- EXPECT_EQ(-1, parsed_time.ToTimeT());
-}
-
-// If time_t is 32 bits, a date after year 2038 will overflow time_t and
-// cause timegm() to return -1. The parsed time should not be 1 second
-// before epoch.
-TEST_F(PRTimeTest, ParseTimeTestEpochNotNeg1) {
- Time parsed_time;
-
- EXPECT_TRUE(Time::FromString(L"Wed Dec 31 23:59:59 GMT 2100",
- &parsed_time));
- EXPECT_NE(-1, parsed_time.ToTimeT());
-}
-
-TEST_F(PRTimeTest, ParseTimeTestEpochNeg2) {
- Time parsed_time;
-
- // time_t == 2 seconds before epoch == -2
- EXPECT_TRUE(Time::FromString(L"Thu Jan 01 00:59:58 +0100 1970",
- &parsed_time));
- EXPECT_EQ(-2, parsed_time.ToTimeT());
- EXPECT_TRUE(Time::FromString(L"Wed Dec 31 23:59:58 GMT 1969",
- &parsed_time));
- EXPECT_EQ(-2, parsed_time.ToTimeT());
-}
-
-TEST_F(PRTimeTest, ParseTimeTestEpoch1960) {
- Time parsed_time;
-
- // time_t before Epoch, in 1960
- EXPECT_TRUE(Time::FromString(L"Wed Jun 29 19:40:01 +0100 1960",
- &parsed_time));
- EXPECT_EQ(-299999999, parsed_time.ToTimeT());
- EXPECT_TRUE(Time::FromString(L"Wed Jun 29 18:40:01 GMT 1960",
- &parsed_time));
- EXPECT_EQ(-299999999, parsed_time.ToTimeT());
- EXPECT_TRUE(Time::FromString(L"Wed Jun 29 17:40:01 GMT 1960",
- &parsed_time));
- EXPECT_EQ(-300003599, parsed_time.ToTimeT());
-}
-
-TEST_F(PRTimeTest, ParseTimeTestEmpty) {
- Time parsed_time;
- EXPECT_FALSE(Time::FromString(L"", &parsed_time));
-}
-
-// This test should not crash when compiled with Visual C++ 2005 (see
-// http://crbug.com/4387).
-TEST_F(PRTimeTest, ParseTimeTestOutOfRange) {
- PRTime parsed_time = 0;
- // Note the lack of timezone in the time string. The year has to be 3001.
- // The date has to be after 23:59:59, December 31, 3000, US Pacific Time, so
- // we use January 2, 3001 to make sure it's after the magic maximum in any
- // timezone.
- PRStatus result = PR_ParseTimeString("Sun Jan 2 00:00:00 3001",
- PR_FALSE, &parsed_time);
- EXPECT_EQ(PR_SUCCESS, result);
-}
-
-TEST_F(PRTimeTest, ParseTimeTestNotNormalized1) {
- PRTime parsed_time = 0;
- PRStatus result = PR_ParseTimeString("Mon Oct 15 12:44:60 PDT 2007",
- PR_FALSE, &parsed_time);
- EXPECT_EQ(PR_SUCCESS, result);
- EXPECT_EQ(comparison_time_pdt, parsed_time);
-}
-
-TEST_F(PRTimeTest, ParseTimeTestNotNormalized2) {
- PRTime parsed_time = 0;
- PRStatus result = PR_ParseTimeString("Sun Oct 14 36:45 PDT 2007",
- PR_FALSE, &parsed_time);
- EXPECT_EQ(PR_SUCCESS, result);
- EXPECT_EQ(comparison_time_pdt, parsed_time);
-}
} // namespace