1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-08-01 08:15:43 +08:00

Rework package structure for unixfs and subpackage

cc @jbenet
This commit is contained in:
Jeromy
2014-10-08 21:14:18 +00:00
parent 15a4701003
commit 093c8fb04d
19 changed files with 81 additions and 66 deletions

36
unixfs/format_test.go Normal file
View File

@ -0,0 +1,36 @@
package unixfs
import (
"testing"
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/goprotobuf/proto"
)
func TestMultiBlock(t *testing.T) {
mbf := new(MultiBlock)
for i := 0; i < 15; i++ {
mbf.AddBlockSize(100)
}
mbf.Data = make([]byte, 128)
b, err := mbf.GetBytes()
if err != nil {
t.Fatal(err)
}
pbn := new(PBData)
err = proto.Unmarshal(b, pbn)
if err != nil {
t.Fatal(err)
}
ds, err := DataSize(b)
if err != nil {
t.Fatal(err)
}
if ds != (100*15)+128 {
t.Fatal("Datasize calculations incorrect!")
}
}