Commit 0d1ba52e authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent e08c206a
...@@ -15,6 +15,8 @@ package fs1 ...@@ -15,6 +15,8 @@ package fs1
import ( import (
"bytes" "bytes"
"fmt"
"io"
"reflect" "reflect"
"testing" "testing"
...@@ -109,62 +111,70 @@ func TestLoad(t *testing.T) { ...@@ -109,62 +111,70 @@ func TestLoad(t *testing.T) {
// check iterating XXX move to separate test ? // check iterating XXX move to separate test ?
// tids we will use for tid{Min,Max} // tids we will use for tid{Min,Max}
tidv := []zodb.Tid{zodb.Tid(0)} tidv := []zodb.Tid{}
for _, dbe := range _1fs_dbEntryv { for _, dbe := range _1fs_dbEntryv {
//tidv = append(tidv, dbe.Header.Tid-1) // XXX here?
tidv = append(tidv, dbe.Header.Tid) tidv = append(tidv, dbe.Header.Tid)
//tidv = append(tidv, dbe.Header.Tid+1) // XXX here?
} }
tidv = append(tidv, zodb.TidMax)
// XXX i -> iMin, j -> iMax ? // XXX i -> iMin, j -> iMax ?
for i, tidMin := range tidv { for i, tidMin := range tidv {
// TODO test both tidMin, and tidMin - 1 minv := []zodb.Tid{tidMin-1, tidMin, tidMin+1}
for j, tidMax := range tidv { for j, tidMax := range tidv {
// TODO test both tidMax, and tidMax + 1 maxv := []zodb.Tid{tidMax-1, tidMax, tidMax+1}
_ = j // XXX
iter := fs.Iterate(tidMin, tidMax) for ii, tmin := range minv {
for jj, tmax := range maxv {
iter := fs.Iterate(tmin, tmax)
// expected number of iteration steps
nsteps := j - i + 1
nsteps -= ii / 2 // one less point for tidMin+1
nsteps -= (2 - jj) / 2 // one less point for tidMax-1
if nsteps < 0 {
nsteps = 0 // j < i and j == i and ii/jj
}
if tidMin > tidMax { for k := 0; ; k++ {
// expect error / panic or empty iteration ? subj := fmt.Sprintf("iterating %v..%v: step %v/%v", tmin, tmax, k+1, nsteps)
} if k >= nsteps {
t.Errorf("%v: steps overrun", subj)
}
//txni := zodb.TxnInfo{} txni, dataIter, err := iter.NextTxn()
//datai := zodb.StorageRecordInformation{} if err != nil {
if err == io.EOF {
if k != nsteps - 1 {
t.Errorf("%v: steps underrun", subj)
}
break
}
t.Errorf("%v: %v", subj, err)
}
for k := 0; ; k++ { dbe := _1fs_dbEntryv[i + k]
txni, dataIter, err := iter.NextTxn()
if err != nil {
err = okEOF(err)
break
}
// XXX vvv assumes i < j // TODO also check .Pos, .LenPrev, .Len
// FIXME first tidMin and last tidMax if !reflect.DeepEqual(*txni, dbe.Header.TxnInfo) {
dbe := _1fs_dbEntryv[i + k] // XXX fatal temp
t.Fatalf("%v: unexpected txn entry:\nhave: %q\nwant: %q", subj, *txni, dbe.Header.TxnInfo)
}
// TODO also check .Pos, .LenPrev, .Len for {
if !reflect.DeepEqual(*txni, dbe.Header.TxnInfo) { datai, err := dataIter.NextData()
t.Errorf("iterating %v..%v: step %v: unexpected txn entry:\nhave: %q\nwant: %q", tidMin, tidMax, k, *txni, dbe.Header.TxnInfo) if err != nil {
} err = okEOF(err)
break
}
for { _ = datai
datai, err := dataIter.NextData() }
if err != nil {
err = okEOF(err)
break
}
_ = datai // TODO check err
}
// TODO check err
}
}
} }
// TODO check err
} }
} }
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment