diff options
author | Ben Johnson <benbjohnson@yahoo.com> | 2014-06-03 13:21:28 -0600 |
---|---|---|
committer | Ben Johnson <benbjohnson@yahoo.com> | 2014-06-03 13:40:24 -0600 |
commit | 54cad40a785deddda2d4b903f048fdfb43a94927 (patch) | |
tree | c4d06f342b5e53d5eea7a34d3d5138db74f26b15 /db_test.go | |
parent | Allow split nodes to be merged with the next node. (diff) | |
download | dedo-54cad40a785deddda2d4b903f048fdfb43a94927.tar.gz dedo-54cad40a785deddda2d4b903f048fdfb43a94927.tar.xz |
Fix merge-split spill issues.
Diffstat (limited to 'db_test.go')
-rw-r--r-- | db_test.go | 34 |
1 files changed, 34 insertions, 0 deletions
@@ -7,6 +7,8 @@ import ( "io/ioutil" "os" "regexp" + "sort" + "strings" "testing" "time" "unsafe" @@ -520,6 +522,38 @@ func mustCheck(db *DB) { } } +// mustContainKeys checks that a bucket contains a given set of keys. +func mustContainKeys(b *Bucket, m map[string]string) { + found := make(map[string]string) + b.ForEach(func(k, _ []byte) error { + found[string(k)] = "" + return nil + }) + + // Check for keys found in bucket that shouldn't be there. + var keys []string + for k, _ := range found { + if _, ok := m[string(k)]; !ok { + keys = append(keys, k) + } + } + if len(keys) > 0 { + sort.Strings(keys) + panic(fmt.Sprintf("keys found(%d): %s", len(keys), strings.Join(keys, ","))) + } + + // Check for keys not found in bucket that should be there. + for k, _ := range m { + if _, ok := found[string(k)]; !ok { + keys = append(keys, k) + } + } + if len(keys) > 0 { + sort.Strings(keys) + panic(fmt.Sprintf("keys not found(%d): %s", len(keys), strings.Join(keys, ","))) + } +} + func trunc(b []byte, length int) []byte { if length < len(b) { return b[:length] |