Skip to content

Commit

Permalink
add. test about enc
Browse files Browse the repository at this point in the history
  • Loading branch information
templexxx committed Sep 6, 2017
1 parent 674e871 commit 818960f
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 7 deletions.
13 changes: 7 additions & 6 deletions rs_amd64.s
Original file line number Diff line number Diff line change
Expand Up @@ -410,10 +410,11 @@ TEXT ·hasSSSE3(SB), NOSPLIT, $0

// func copy32B(dst, src []byte)
TEXT ·copy32B(SB), NOSPLIT, $0
MOVQ dst+0(FP), AX
MOVQ src+24(FP), BX
MOVOU (BX), X0
MOVOU 16(BX), X1
MOVOU X0, (AX)
MOVOU X1, 16(AX)
MOVQ dst+0(FP), SI
MOVQ src+24(FP), DX
MOVOU (DX), X0
MOVOU 16(DX), X1
MOVOU X0, (SI)
MOVOU X1, 16(SI)
RET

41 changes: 40 additions & 1 deletion rs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func fillRandom(v []byte) {
}
}

func verifyReconst(t *testing.T, d, p int, lost []int) {
func verifyEnc(t *testing.T, d, p int) {
for i := 1; i <= verifySize; i++ {
vects1 := make([][]byte, d+p)
vects2 := make([][]byte, d+p)
Expand All @@ -89,6 +89,45 @@ func verifyReconst(t *testing.T, d, p int, lost []int) {
if err != nil {
t.Fatal(err)
}
em, err := genEncMatrixVand(d, p)
if err != nil {
t.Fatal(err)
}
g := em[d*d:]
e2 := &encBase{data: d, parity: p, gen: g}
err = e2.Encode(vects2)
for k, v1 := range vects1 {
if !bytes.Equal(v1, vects2[k]) {
t.Fatalf("no match enc with encBase; vect: %d; size: %d", k, i)
}
}
}
}

func TestVerifyEnc(t *testing.T) {
verifyEnc(t, testNumIn, testNumOut)
}

func verifyReconst(t *testing.T, d, p int, lost []int) {
for i := 1; i <= verifySize; i++ {
vects1 := make([][]byte, d+p)
vects2 := make([][]byte, d+p)
for j := 0; j < d+p; j++ {
vects1[j] = make([]byte, i)
vects2[j] = make([]byte, i)
}
for j := 0; j < d; j++ {
rand.Seed(int64(j))
fillRandom(vects1[j])
}
e, err := New(d, p)
if err != nil {
t.Fatal(err)
}
err = e.Encode(vects1)
if err != nil {
t.Fatal(err)
}
for j := 0; j < d+p; j++ {
copy(vects2[j], vects1[j])
}
Expand Down

0 comments on commit 818960f

Please sign in to comment.