Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
4f009290
Commit
4f009290
authored
Nov 05, 2014
by
Taylor Gerring
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added byte padding tests
parent
94b0ce84
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
60 additions
and
0 deletions
+60
-0
bytes_test.go
ethutil/bytes_test.go
+60
-0
No files found.
ethutil/bytes_test.go
View file @
4f009290
...
@@ -12,3 +12,63 @@ func TestParseData(t *testing.T) {
...
@@ -12,3 +12,63 @@ func TestParseData(t *testing.T) {
t
.
Error
(
"Error parsing data"
)
t
.
Error
(
"Error parsing data"
)
}
}
}
}
func
TestLeftPadBytes
(
t
*
testing
.
T
)
{
val
:=
[]
byte
{
1
,
2
,
3
,
4
}
exp
:=
[]
byte
{
0
,
0
,
0
,
0
,
1
,
2
,
3
,
4
}
resstd
:=
LeftPadBytes
(
val
,
8
)
if
bytes
.
Compare
(
resstd
,
exp
)
!=
0
{
t
.
Errorf
(
"Expected % x Got % x"
,
exp
,
resstd
)
}
resshrt
:=
LeftPadBytes
(
val
,
2
)
if
bytes
.
Compare
(
resshrt
,
val
)
!=
0
{
t
.
Errorf
(
"Expected % x Got % x"
,
exp
,
resshrt
)
}
}
func
TestRightPadBytes
(
t
*
testing
.
T
)
{
val
:=
[]
byte
{
1
,
2
,
3
,
4
}
exp
:=
[]
byte
{
1
,
2
,
3
,
4
,
0
,
0
,
0
,
0
}
resstd
:=
RightPadBytes
(
val
,
8
)
if
bytes
.
Compare
(
resstd
,
exp
)
!=
0
{
t
.
Errorf
(
"Expected % x Got % x"
,
exp
,
resstd
)
}
resshrt
:=
RightPadBytes
(
val
,
2
)
if
bytes
.
Compare
(
resshrt
,
val
)
!=
0
{
t
.
Errorf
(
"Expected % x Got % x"
,
exp
,
resshrt
)
}
}
func
TestLeftPadString
(
t
*
testing
.
T
)
{
val
:=
"test"
resstd
:=
LeftPadString
(
val
,
8
)
if
resstd
!=
"
\x30\x30\x30\x30
"
+
val
{
t
.
Errorf
(
"Expected % x Got % x"
,
val
,
resstd
)
}
resshrt
:=
LeftPadString
(
val
,
2
)
if
resshrt
!=
val
{
t
.
Errorf
(
"Expected % x Got % x"
,
val
,
resshrt
)
}
}
func
TestRightPadString
(
t
*
testing
.
T
)
{
val
:=
"test"
resstd
:=
RightPadString
(
val
,
8
)
if
resstd
!=
val
+
"
\x30\x30\x30\x30
"
{
t
.
Errorf
(
"Expected % x Got % x"
,
val
,
resstd
)
}
resshrt
:=
RightPadString
(
val
,
2
)
if
resshrt
!=
val
{
t
.
Errorf
(
"Expected % x Got % x"
,
val
,
resshrt
)
}
}
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