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
b96a59eb
Commit
b96a59eb
authored
Nov 04, 2014
by
Taylor Gerring
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added tests for extra large values
Test “E” scientific notation formatting
parent
e7d9bcd3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
0 deletions
+19
-0
common.go
ethutil/common.go
+1
-0
common_test.go
ethutil/common_test.go
+18
-0
No files found.
ethutil/common.go
View file @
b96a59eb
...
@@ -66,6 +66,7 @@ func CurrencyToString(num *big.Int) string {
...
@@ -66,6 +66,7 @@ func CurrencyToString(num *big.Int) string {
denom
=
"Ada"
denom
=
"Ada"
}
}
// TODO add comment clarifying expected behavior
if
len
(
fin
.
String
())
>
5
{
if
len
(
fin
.
String
())
>
5
{
return
fmt
.
Sprintf
(
"%sE%d %s"
,
fin
.
String
()[
0
:
5
],
len
(
fin
.
String
())
-
5
,
denom
)
return
fmt
.
Sprintf
(
"%sE%d %s"
,
fin
.
String
()[
0
:
5
],
len
(
fin
.
String
())
-
5
,
denom
)
}
}
...
...
ethutil/common_test.go
View file @
b96a59eb
...
@@ -79,3 +79,21 @@ func TestCommon(t *testing.T) {
...
@@ -79,3 +79,21 @@ func TestCommon(t *testing.T) {
t
.
Error
(
"Got"
,
wei
)
t
.
Error
(
"Got"
,
wei
)
}
}
}
}
func
TestLarge
(
t
*
testing
.
T
)
{
douglaslarge
:=
CurrencyToString
(
BigPow
(
100000000
,
43
))
adalarge
:=
CurrencyToString
(
BigPow
(
100000000
,
4
))
weilarge
:=
CurrencyToString
(
big
.
NewInt
(
100000000
))
if
douglaslarge
!=
"10000E298 Douglas"
{
t
.
Error
(
"Got"
,
douglaslarge
)
}
if
adalarge
!=
"10000E7 Einstein"
{
t
.
Error
(
"Got"
,
adalarge
)
}
if
weilarge
!=
"100 Babbage"
{
t
.
Error
(
"Got"
,
weilarge
)
}
}
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