mirror of
https://github.com/fumiama/unibase2n.git
synced 2026-06-28 16:00:33 +08:00
complete all encode & unit test
This commit is contained in:
25
len_test.go
25
len_test.go
@@ -1,6 +1,10 @@
|
||||
package unibase2n
|
||||
|
||||
import "testing"
|
||||
import (
|
||||
"testing"
|
||||
|
||||
base14 "github.com/fumiama/go-base16384"
|
||||
)
|
||||
|
||||
func TestEnDecodeLen(t *testing.T) {
|
||||
bs := Base{bit: 1}
|
||||
@@ -13,3 +17,22 @@ func TestEnDecodeLen(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestBase16384EnDecodeLen(t *testing.T) {
|
||||
bs := Base{bit: 14}
|
||||
for i := 1; i <= 65536; i++ {
|
||||
myi, _ := bs.EncodeLen(i)
|
||||
aci := base14.EncodeLen(i)
|
||||
if myi != aci {
|
||||
t.Fatal("bit:", bs.bit, "input:", i, "me:", myi, "!= actual:", aci)
|
||||
}
|
||||
}
|
||||
for i := 1; i <= 4096; i++ {
|
||||
myi, off := bs.EncodeLen(i)
|
||||
myo := bs.DecodeLen(myi, off)
|
||||
aco := base14.DecodeLen(myi, off)
|
||||
if myo != aco {
|
||||
t.Fatal("bit:", bs.bit, "input:", i, "me:", myo, "!= actual:", aco)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user