Ensure that a freelist can serialize into a freelist page.
(t *testing.T)
| 334 | |
| 335 | // Ensure that a freelist can serialize into a freelist page. |
| 336 | func TestFreelist_write(t *testing.T) { |
| 337 | // Create a freelist and write it to a page. |
| 338 | var buf [4096]byte |
| 339 | f := newTestFreelist() |
| 340 | |
| 341 | f.Init([]common.Pgid{12, 39}) |
| 342 | f.pendingPageIds()[100] = &txPending{ids: []common.Pgid{28, 11}} |
| 343 | f.pendingPageIds()[101] = &txPending{ids: []common.Pgid{3}} |
| 344 | p := (*common.Page)(unsafe.Pointer(&buf[0])) |
| 345 | f.Write(p) |
| 346 | |
| 347 | // Read the page back out. |
| 348 | f2 := newTestFreelist() |
| 349 | f2.Read(p) |
| 350 | |
| 351 | // Ensure that the freelist is correct. |
| 352 | // All pages should be present and in reverse order. |
| 353 | if exp := common.Pgids([]common.Pgid{3, 11, 12, 28, 39}); !reflect.DeepEqual(exp, f2.freePageIds()) { |
| 354 | t.Fatalf("exp=%v; got=%v", exp, f2.freePageIds()) |
| 355 | } |
| 356 | } |
| 357 | |
| 358 | func TestFreelist_E2E_HappyPath(t *testing.T) { |
| 359 | f := newTestFreelist() |
nothing calls this directly
no test coverage detected