1
0
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:
源文雨
2022-10-01 14:53:17 +08:00
parent a68a04bbe9
commit 08228b7a61
10 changed files with 449 additions and 66 deletions

View File

@@ -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)
}
}
}