Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
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
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
7b69af3b
Commit
7b69af3b
authored
Oct 22, 2017
by
Tamal Saha
Committed by
tamal
Oct 24, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix NPE in time.Equal method
parent
6f06408e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
1 deletion
+31
-1
time.go
staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/time.go
+7
-1
time_test.go
...ing/src/k8s.io/apimachinery/pkg/apis/meta/v1/time_test.go
+24
-0
No files found.
staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/time.go
View file @
7b69af3b
...
...
@@ -80,7 +80,13 @@ func (t *Time) Before(u *Time) bool {
// Equal reports whether the time instant t is equal to u.
func
(
t
*
Time
)
Equal
(
u
*
Time
)
bool
{
return
t
.
Time
.
Equal
(
u
.
Time
)
if
t
==
nil
&&
u
==
nil
{
return
true
}
if
t
!=
nil
&&
u
!=
nil
{
return
t
.
Time
.
Equal
(
u
.
Time
)
}
return
false
}
// Unix returns the local time corresponding to the given Unix time
...
...
staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/time_test.go
View file @
7b69af3b
...
...
@@ -171,3 +171,27 @@ func TestTimeProto(t *testing.T) {
}
}
}
func
TestTimeEqual
(
t
*
testing
.
T
)
{
t1
:=
NewTime
(
time
.
Now
())
cases
:=
[]
struct
{
name
string
x
*
Time
y
*
Time
result
bool
}{
{
"nil =? nil"
,
nil
,
nil
,
true
},
{
"!nil =? !nil"
,
&
t1
,
&
t1
,
true
},
{
"nil =? !nil"
,
nil
,
&
t1
,
false
},
{
"!nil =? nil"
,
&
t1
,
nil
,
false
},
}
for
_
,
c
:=
range
cases
{
t
.
Run
(
c
.
name
,
func
(
t
*
testing
.
T
)
{
result
:=
c
.
x
.
Equal
(
c
.
y
)
if
result
!=
c
.
result
{
t
.
Errorf
(
"Failed equality test for '%v', '%v': expected %+v, got %+v"
,
c
.
x
,
c
.
y
,
c
.
result
,
result
)
}
})
}
}
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