diff options
author | Ben Johnson <benbjohnson@yahoo.com> | 2014-05-19 14:11:32 -0600 |
---|---|---|
committer | Ben Johnson <benbjohnson@yahoo.com> | 2014-05-19 14:11:32 -0600 |
commit | 12b36fe70c3dee7f8ae9a1e2b68f76e1d9c4cd71 (patch) | |
tree | 604e58d3f0b1a6a72b9989822dcb8ff1a4c97b9e /freelist_test.go | |
parent | Fix freelist allocation direction. (diff) | |
download | dedo-12b36fe70c3dee7f8ae9a1e2b68f76e1d9c4cd71.tar.gz dedo-12b36fe70c3dee7f8ae9a1e2b68f76e1d9c4cd71.tar.xz |
Fix freelist allocate().
Diffstat (limited to 'freelist_test.go')
-rw-r--r-- | freelist_test.go | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/freelist_test.go b/freelist_test.go index 00c71cf..5948f3b 100644 --- a/freelist_test.go +++ b/freelist_test.go @@ -29,9 +29,9 @@ func TestFreelist_release(t *testing.T) { f.free(102, &page{id: 39}) f.release(100) f.release(101) - assert.Equal(t, f.ids, []pgid{13, 12, 9}) + assert.Equal(t, []pgid{9, 12, 13}, f.ids) f.release(102) - assert.Equal(t, f.ids, []pgid{39, 13, 12, 9}) + assert.Equal(t, []pgid{9, 12, 13, 39}, f.ids) } // Ensure that a freelist can find contiguous blocks of pages. @@ -44,6 +44,10 @@ func TestFreelist_allocate(t *testing.T) { assert.Equal(t, 7, int(f.allocate(1))) assert.Equal(t, 0, int(f.allocate(0))) assert.Equal(t, []pgid{9, 18}, f.ids) + assert.Equal(t, 9, int(f.allocate(1))) + assert.Equal(t, 18, int(f.allocate(1))) + assert.Equal(t, 0, int(f.allocate(1))) + assert.Equal(t, []pgid{}, f.ids) } // Ensure that a freelist can deserialize from a freelist page. @@ -86,9 +90,9 @@ func TestFreelist_write(t *testing.T) { // Ensure that the freelist is correct. // All pages should be present and in reverse order. assert.Equal(t, len(f2.ids), 5) - assert.Equal(t, f2.ids[0], pgid(39)) - assert.Equal(t, f2.ids[1], pgid(28)) + assert.Equal(t, f2.ids[0], pgid(3)) + assert.Equal(t, f2.ids[1], pgid(11)) assert.Equal(t, f2.ids[2], pgid(12)) - assert.Equal(t, f2.ids[3], pgid(11)) - assert.Equal(t, f2.ids[4], pgid(3)) + assert.Equal(t, f2.ids[3], pgid(28)) + assert.Equal(t, f2.ids[4], pgid(39)) } |