优化64进制转换
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
package convx_test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math"
|
||||
"testing"
|
||||
|
||||
"code.yun.ink/pkg/convx"
|
||||
)
|
||||
|
||||
func Test10to64(t *testing.T) {
|
||||
var tests = []struct {
|
||||
in int64
|
||||
}{
|
||||
{math.MaxInt64},
|
||||
{-987654321},
|
||||
// {-1234567890},
|
||||
// {-987654321},
|
||||
{0},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
s, err := convx.Encode10To64(test.in)
|
||||
fmt.Println(test.in, s, err)
|
||||
n, err := convx.Decode64To10(s)
|
||||
fmt.Println(n, err)
|
||||
if n != test.in {
|
||||
t.Errorf("10to64: %d != %d", n, test.in)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user