aboutsummaryrefslogtreecommitdiff
path: root/db_test.go
diff options
context:
space:
mode:
authorBen Johnson <benbjohnson@yahoo.com>2014-02-11 12:16:12 -0700
committerBen Johnson <benbjohnson@yahoo.com>2014-02-12 11:49:57 -0700
commit7bb878ff695b89b62483dd6155f5815ad0d06258 (patch)
tree1ec591c5aca7bfc099a98433f6a7b01e28c1d9db /db_test.go
parentMerge branch 'master' of https://github.com/boltdb/bolt (diff)
downloaddedo-7bb878ff695b89b62483dd6155f5815ad0d06258.tar.gz
dedo-7bb878ff695b89b62483dd6155f5815ad0d06258.tar.xz
Mmap remap.
Diffstat (limited to 'db_test.go')
-rw-r--r--db_test.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/db_test.go b/db_test.go
index 8211eac..db57825 100644
--- a/db_test.go
+++ b/db_test.go
@@ -187,6 +187,18 @@ func TestDBWriteFail(t *testing.T) {
t.Skip("pending") // TODO(benbjohnson)
}
+// Ensure that the mmap grows appropriately.
+func TestDBMmapSize(t *testing.T) {
+ db := &DB{pageSize: 4096}
+ assert.Equal(t, db.mmapSize(0), minMmapSize)
+ assert.Equal(t, db.mmapSize(16384), minMmapSize)
+ assert.Equal(t, db.mmapSize(minMmapSize-1), minMmapSize)
+ assert.Equal(t, db.mmapSize(minMmapSize), minMmapSize*2)
+ assert.Equal(t, db.mmapSize(10000000), 20000768)
+ assert.Equal(t, db.mmapSize((1<<30)-1), 2147483648)
+ assert.Equal(t, db.mmapSize(1<<30), 1<<31)
+}
+
// withDB executes a function with a database reference.
func withDB(fn func(*DB, string)) {
f, _ := ioutil.TempFile("", "bolt-")