From 7bb878ff695b89b62483dd6155f5815ad0d06258 Mon Sep 17 00:00:00 2001 From: Ben Johnson Date: Tue, 11 Feb 2014 12:16:12 -0700 Subject: Mmap remap. --- db_test.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'db_test.go') 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-") -- cgit v1.2.3