Commit 20d53f7a authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 8cde7ef9
...@@ -19,7 +19,7 @@ func isNil(p interface{}) bool { ...@@ -19,7 +19,7 @@ func isNil(p interface{}) bool {
} }
return false return false
} }
func (t *Tree) dump() string { func (t *Tree) Dump() string {
var buf bytes.Buffer var buf bytes.Buffer
f := strutil.IndentFormatter(&buf, "\t") f := strutil.IndentFormatter(&buf, "\t")
......
...@@ -42,6 +42,7 @@ echo >>$out ...@@ -42,6 +42,7 @@ echo >>$out
sed -n \ sed -n \
-e '/^func isNil(/,/^}/p' \ -e '/^func isNil(/,/^}/p' \
-e '/^func.* dump()/,/^}/ { -e '/^func.* dump()/,/^}/ {
s/dump()/Dump()/g
s/v\.k != nil/true/g s/v\.k != nil/true/g
s/v\.v != nil/(true || \&v != nil)/g s/v\.v != nil/(true || \&v != nil)/g
p p
......
...@@ -3,9 +3,11 @@ ...@@ -3,9 +3,11 @@
package fs1 package fs1
import ( import (
"fmt"
"io/ioutil" "io/ioutil"
"os" "os"
"sort" "sort"
"strings"
"testing" "testing"
"../../zodb" "../../zodb"
...@@ -56,6 +58,9 @@ func treeEqual(a, b *fsb.Tree) bool { ...@@ -56,6 +58,9 @@ func treeEqual(a, b *fsb.Tree) bool {
return true return true
} }
defer ea.Close()
defer eb.Close()
for { for {
ka, va, stopa := ea.Next() ka, va, stopa := ea.Next()
kb, vb, stopb := eb.Next() kb, vb, stopb := eb.Next()
...@@ -75,6 +80,24 @@ func treeEqual(a, b *fsb.Tree) bool { ...@@ -75,6 +80,24 @@ func treeEqual(a, b *fsb.Tree) bool {
return true return true
} }
func treeString(t *fsb.Tree) string {
entryv := []string{}
e, _ := t.SeekFirst()
if e != nil {
defer e.Close()
for {
k, v, stop := e.Next()
if stop != nil {
break
}
entryv = append(entryv, fmt.Sprintf("%v: %v", k, v))
}
}
return "{" + strings.Join(entryv, ", ") + "}"
}
func TestIndexLookup(t *testing.T) { func TestIndexLookup(t *testing.T) {
// the lookup is tested in cznic.b itself // the lookup is tested in cznic.b itself
// here we only lightly exercise it // here we only lightly exercise it
...@@ -161,7 +184,8 @@ func TestIndexSaveLoad(t *testing.T) { ...@@ -161,7 +184,8 @@ func TestIndexSaveLoad(t *testing.T) {
// XXX is it ok to compare trees via reflect.DeepEqual ? // XXX is it ok to compare trees via reflect.DeepEqual ?
if !treeEqual(fsi2.Tree, fsi.Tree) { if !treeEqual(fsi2.Tree, fsi.Tree) {
t.Errorf("index load: trees mismatch: %v ; want %v", fsi2.Tree.dump(), fsi.Tree.dump()) //t.Errorf("index load: trees mismatch:\nhave: %v\nwant: %v", fsi2.Tree.Dump(), fsi.Tree.Dump())
t.Errorf("index load: trees mismatch:\nhave: %v\nwant: %v", treeString(fsi2.Tree), treeString(fsi.Tree))
} }
......
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