25 lines
522 B
Go
25 lines
522 B
Go
|
|
package rest
|
||
|
|
|
||
|
|
import "testing"
|
||
|
|
|
||
|
|
func TestDecimalStringToHex(t *testing.T) {
|
||
|
|
got := decimalStringToHex("1000000000000000000")
|
||
|
|
if got != "0xde0b6b3a7640000" {
|
||
|
|
t.Fatalf("decimalStringToHex() = %s", got)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
func TestNormalizeHexInput(t *testing.T) {
|
||
|
|
tests := map[string]string{
|
||
|
|
"": "0x",
|
||
|
|
"deadbeef": "0xdeadbeef",
|
||
|
|
"0x1234": "0x1234",
|
||
|
|
}
|
||
|
|
|
||
|
|
for input, want := range tests {
|
||
|
|
if got := normalizeHexInput(input); got != want {
|
||
|
|
t.Fatalf("normalizeHexInput(%q) = %q, want %q", input, got, want)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|