diff options
author | Ben Johnson <benbjohnson@yahoo.com> | 2014-06-03 16:44:58 -0600 |
---|---|---|
committer | Ben Johnson <benbjohnson@yahoo.com> | 2014-06-03 16:44:58 -0600 |
commit | 510143d852e394d2fb5fb773bab41f1d9e35d602 (patch) | |
tree | c4d06f342b5e53d5eea7a34d3d5138db74f26b15 /db_test.go | |
parent | Add ipxed to README. (diff) | |
parent | Fix merge-split spill issues. (diff) | |
download | dedo-510143d852e394d2fb5fb773bab41f1d9e35d602.tar.gz dedo-510143d852e394d2fb5fb773bab41f1d9e35d602.tar.xz |
Merge pull request #181 from benbjohnson/split-merge
Allow split nodes to be merged with the next node.
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] |