5 Star 29 Fork 12

楠木 / etherscan-api

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
helper_test.go 1.15 KB
一键复制 编辑 Web IDE 原始数据 按行查看 历史
楠木 提交于 2018-08-04 23:27 . [dev] add test case
/*
* Copyright (c) 2018 LI Zhennan
*
* Use of this work is governed by a MIT License.
* You may find a license copy in project root.
*/
package etherscan
import (
"math/big"
"testing"
"time"
)
func TestBigInt(t *testing.T) {
const ansStr = "255"
var ans = big.NewInt(255)
b := new(BigInt)
err := b.UnmarshalText([]byte(ansStr))
noError(t, err, "BigInt.UnmarshalText")
if b.Int().Cmp(ans) != 0 {
t.Fatalf("BigInt.UnmarshalText not working, got %v, want %v", b.Int(), ans)
}
textBytes, err := b.MarshalText()
noError(t, err, "BigInt.MarshalText")
if string(textBytes) != ansStr {
t.Fatalf("BigInt.MarshalText not working, got %s, want %s", textBytes, ansStr)
}
}
func TestTime(t *testing.T) {
const ansStr = "1533396289"
var ans = time.Unix(1533396289, 0)
b := new(Time)
err := b.UnmarshalText([]byte(ansStr))
noError(t, err, "Time.UnmarshalText")
if !b.Time().Equal(ans) {
t.Fatalf("Time.UnmarshalText not working, got %v, want %v", b, ans)
}
textBytes, err := b.MarshalText()
noError(t, err, "BigInt.MarshalText")
if string(textBytes) != ansStr {
t.Fatalf("Time.MarshalText not working, got %s, want %s", textBytes, ansStr)
}
}
Go
1
https://gitee.com/nanmu42/etherscan-api.git
git@gitee.com:nanmu42/etherscan-api.git
nanmu42
etherscan-api
etherscan-api
master

搜索帮助