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
9ed6c95e
Commit
9ed6c95e
authored
Mar 23, 2015
by
Tim Hockin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reset hash state between runs.
parent
c35593a7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
0 deletions
+7
-0
hash.go
pkg/util/hash.go
+1
-0
hash_test.go
pkg/util/hash_test.go
+6
-0
No files found.
pkg/util/hash.go
View file @
9ed6c95e
...
...
@@ -26,6 +26,7 @@ import (
// which follows pointers and prints actual values of the nested objects
// ensuring the hash does not change when a pointer changes.
func
DeepHashObject
(
hasher
hash
.
Hash
,
objectToWrite
interface
{})
{
hasher
.
Reset
()
printer
:=
spew
.
ConfigState
{
Indent
:
" "
,
SortKeys
:
true
}
printer
.
Fprintf
(
hasher
,
"%#v"
,
objectToWrite
)
}
pkg/util/hash_test.go
View file @
9ed6c95e
...
...
@@ -49,12 +49,18 @@ func TestDeepObjectPointer(t *testing.T) {
// Act
DeepHashObject
(
hasher1
,
myUni1
)
hash1
:=
hasher1
.
Sum32
()
DeepHashObject
(
hasher1
,
myUni1
)
hash1a
:=
hasher1
.
Sum32
()
DeepHashObject
(
hasher2
,
myUni2
)
hash2
:=
hasher2
.
Sum32
()
DeepHashObject
(
hasher3
,
myUni3
)
hash3
:=
hasher3
.
Sum32
()
// Assert
if
hash1
!=
hash1a
{
t
.
Errorf
(
"repeated hash of the same object produced different results: %d vs %d"
,
hash1
,
hash1a
)
}
if
hash1
==
hash2
{
t
.
Errorf
(
"hash1 (%d) and hash2(%d) must be different because they have different values for wheel size"
,
hash1
,
hash2
)
}
...
...
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