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

Side by Side Diff: chrome/browser/sync/notifier/base/time_unittest.cc

Issue 194065: Initial commit of sync engine code to browser/sync.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Fixes to gtest include path, reverted syncapi. Created 11 years, 3 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 | Annotate | Revision Log
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 // Copyright (c) 2009 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 "chrome/browser/sync/notifier/base/time.h"
6 #include "notifier/testing/notifier/unittest.h"
7
8 namespace notifier {
9
10 TEST_NOTIFIER_F(TimeTest);
11
12 TEST_F(TimeTest, ParseRFC822DateTime) {
13 struct tm t = {0};
14
15 EXPECT_TRUE(ParseRFC822DateTime("Mon, 16 May 2005 15:44:18 -0700",
16 &t, false));
17 EXPECT_EQ(t.tm_year, 2005 - 1900);
18 EXPECT_EQ(t.tm_mon, 4);
19 EXPECT_EQ(t.tm_mday, 16);
20 EXPECT_EQ(t.tm_hour, 22);
21 EXPECT_EQ(t.tm_min, 44);
22 EXPECT_EQ(t.tm_sec, 18);
23
24 EXPECT_TRUE(ParseRFC822DateTime("Mon, 16 May 2005 15:44:18 -0700", &t, true));
25 EXPECT_EQ(t.tm_year, 2005 - 1900);
26 EXPECT_EQ(t.tm_mon, 4);
27 EXPECT_EQ(t.tm_mday, 16);
28 EXPECT_TRUE(t.tm_hour == 15 || t.tm_hour == 14); // daylight saving time
29 EXPECT_EQ(t.tm_min, 44);
30 EXPECT_EQ(t.tm_sec , 18);
31
32 EXPECT_TRUE(ParseRFC822DateTime("Tue, 17 May 2005 02:56:18 +0400",
33 &t, false));
34 EXPECT_EQ(t.tm_year, 2005 - 1900);
35 EXPECT_EQ(t.tm_mon, 4);
36 EXPECT_EQ(t.tm_mday, 16);
37 EXPECT_EQ(t.tm_hour, 22);
38 EXPECT_EQ(t.tm_min, 56);
39 EXPECT_EQ(t.tm_sec , 18);
40
41 EXPECT_TRUE(ParseRFC822DateTime("Tue, 17 May 2005 02:56:18 +0400", &t, true));
42 EXPECT_EQ(t.tm_year, 2005 - 1900);
43 EXPECT_EQ(t.tm_mon, 4);
44 EXPECT_EQ(t.tm_mday, 16);
45 EXPECT_TRUE(t.tm_hour == 15 || t.tm_hour == 14); // daylight saving time
46 EXPECT_EQ(t.tm_min, 56);
47 EXPECT_EQ(t.tm_sec, 18);
48 }
49
50 TEST_F(TimeTest, ParseStringToTimeSpan) {
51 time64 time_span = 0;
52
53 EXPECT_TRUE(ParseStringToTimeSpan("0:0:4", &time_span));
54 EXPECT_EQ(time_span, 4 * kSecsTo100ns);
55
56 EXPECT_TRUE(ParseStringToTimeSpan("0:3:4", &time_span));
57 EXPECT_EQ(time_span, (3 * 60 + 4) * kSecsTo100ns);
58
59 EXPECT_TRUE(ParseStringToTimeSpan("2:3:4", &time_span));
60 EXPECT_EQ(time_span, (2 * 3600 + 3 * 60 + 4) * kSecsTo100ns);
61
62 EXPECT_TRUE(ParseStringToTimeSpan("1.2:3:4", &time_span));
63 EXPECT_EQ(time_span, (1 * 86400 + 2 * 60 * 60 + 3 * 60 + 4) * kSecsTo100ns);
64
65 EXPECT_FALSE(ParseStringToTimeSpan("2:invalid:4", &time_span));
66 }
67
68 TEST_F(TimeTest, UseLocalTimeAsString) {
69 // Just call it to ensure that it doesn't assert.
70 GetLocalTimeAsString();
71 }
72
73 } // namespace notifier
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698