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
be96da17
Commit
be96da17
authored
Nov 05, 2014
by
Taylor Gerring
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added tests for FormatData
parent
8f94f731
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
0 deletions
+33
-0
bytes_test.go
ethutil/bytes_test.go
+33
-0
No files found.
ethutil/bytes_test.go
View file @
be96da17
...
@@ -127,6 +127,39 @@ func TestLeftPadBytes(t *testing.T) {
...
@@ -127,6 +127,39 @@ func TestLeftPadBytes(t *testing.T) {
}
}
}
}
func
TestFormatData
(
t
*
testing
.
T
)
{
data1
:=
""
data2
:=
"0xa9e67e00"
data3
:=
"a9e67e"
data4
:=
"
\"
a9e67e00
\"
"
exp1
:=
[]
byte
{}
exp2
:=
[]
byte
{
00
,
00
,
00
,
00
,
00
,
00
,
00
,
00
,
00
,
00
,
00
,
00
,
00
,
00
,
00
,
00
,
00
,
00
,
00
,
00
,
00
,
00
,
00
,
00
,
00
,
00
,
00
,
00
,
0xa9
,
0xe6
,
0x7e
,
00
}
exp3
:=
[]
byte
{
00
,
00
,
00
,
00
,
00
,
00
,
00
,
00
,
00
,
00
,
00
,
00
,
00
,
00
,
00
,
00
,
00
,
00
,
00
,
00
,
00
,
00
,
00
,
00
,
00
,
00
,
00
,
00
,
00
,
00
,
00
,
00
}
exp4
:=
[]
byte
{
0x61
,
0x39
,
0x65
,
0x36
,
0x37
,
0x65
,
0x30
,
0x30
,
00
,
00
,
00
,
00
,
00
,
00
,
00
,
00
,
00
,
00
,
00
,
00
,
00
,
00
,
00
,
00
,
00
,
00
,
00
,
00
,
00
,
00
,
00
,
00
}
res1
:=
FormatData
(
data1
)
res2
:=
FormatData
(
data2
)
res3
:=
FormatData
(
data3
)
res4
:=
FormatData
(
data4
)
if
bytes
.
Compare
(
res1
,
exp1
)
!=
0
{
t
.
Errorf
(
"Expected % x Got % x"
,
exp1
,
res1
)
}
if
bytes
.
Compare
(
res2
,
exp2
)
!=
0
{
t
.
Errorf
(
"Expected % x Got % x"
,
exp2
,
res2
)
}
if
bytes
.
Compare
(
res3
,
exp3
)
!=
0
{
t
.
Errorf
(
"Expected % x Got % x"
,
exp3
,
res3
)
}
if
bytes
.
Compare
(
res4
,
exp4
)
!=
0
{
t
.
Errorf
(
"Expected % x Got % x"
,
exp4
,
res4
)
}
}
func
TestRightPadBytes
(
t
*
testing
.
T
)
{
func
TestRightPadBytes
(
t
*
testing
.
T
)
{
val
:=
[]
byte
{
1
,
2
,
3
,
4
}
val
:=
[]
byte
{
1
,
2
,
3
,
4
}
exp
:=
[]
byte
{
1
,
2
,
3
,
4
,
0
,
0
,
0
,
0
}
exp
:=
[]
byte
{
1
,
2
,
3
,
4
,
0
,
0
,
0
,
0
}
...
...
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