Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
P
protobuf
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
protobuf
Commits
b77aa801
Unverified
Commit
b77aa801
authored
Jan 08, 2018
by
Adam Cozzette
Committed by
GitHub
Jan 08, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4148 from datacompboy/patch-2
Add more tests to time_test
parents
d4afdba8
091eeb12
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
53 additions
and
0 deletions
+53
-0
time_test.cc
src/google/protobuf/stubs/time_test.cc
+53
-0
No files found.
src/google/protobuf/stubs/time_test.cc
View file @
b77aa801
...
...
@@ -149,6 +149,59 @@ TEST(DateTimeTest, LeapYear) {
CreateTimestamp
(
2400
,
3
,
1
)
-
CreateTimestamp
(
2400
,
2
,
29
));
}
TEST
(
DateTimeTest
,
WrongDays
)
{
int64
seconds
;
DateTime
time
;
time
.
hour
=
0
;
time
.
minute
=
0
;
time
.
second
=
0
;
time
.
month
=
2
;
// Non-leap year.
time
.
year
=
2015
;
time
.
day
=
29
;
ASSERT_FALSE
(
DateTimeToSeconds
(
time
,
&
seconds
));
// Leap year.
time
.
year
=
2016
;
time
.
day
=
29
;
ASSERT_TRUE
(
DateTimeToSeconds
(
time
,
&
seconds
));
time
.
day
=
30
;
ASSERT_FALSE
(
DateTimeToSeconds
(
time
,
&
seconds
));
// Non-leap year.
time
.
year
=
2100
;
time
.
day
=
29
;
ASSERT_FALSE
(
DateTimeToSeconds
(
time
,
&
seconds
));
// Leap year.
time
.
year
=
2400
;
time
.
day
=
29
;
ASSERT_TRUE
(
DateTimeToSeconds
(
time
,
&
seconds
));
time
.
day
=
30
;
ASSERT_FALSE
(
DateTimeToSeconds
(
time
,
&
seconds
));
// Non-february
time
.
year
=
2015
;
time
.
month
=
1
;
time
.
day
=
0
;
ASSERT_FALSE
(
DateTimeToSeconds
(
time
,
&
seconds
));
time
.
day
=
1
;
ASSERT_TRUE
(
DateTimeToSeconds
(
time
,
&
seconds
));
time
.
day
=
31
;
ASSERT_TRUE
(
DateTimeToSeconds
(
time
,
&
seconds
));
time
.
day
=
32
;
ASSERT_FALSE
(
DateTimeToSeconds
(
time
,
&
seconds
));
// Bad month
time
.
year
=
2015
;
time
.
month
=
0
;
time
.
day
=
1
;
ASSERT_FALSE
(
DateTimeToSeconds
(
time
,
&
seconds
));
time
.
month
=
13
;
ASSERT_FALSE
(
DateTimeToSeconds
(
time
,
&
seconds
));
}
TEST
(
DateTimeTest
,
StringFormat
)
{
DateTime
start
,
end
;
start
.
year
=
1
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment