slotinfopage_test.go 792 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. /*
  2. * EliasDB
  3. *
  4. * Copyright 2016 Matthias Ladkau. All rights reserved.
  5. *
  6. * This Source Code Form is subject to the terms of the Mozilla Public
  7. * License, v. 2.0. If a copy of the MPL was not distributed with this
  8. * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  9. */
  10. package pageview
  11. import (
  12. "testing"
  13. "devt.de/krotik/eliasdb/storage/file"
  14. "devt.de/krotik/eliasdb/storage/paging/view"
  15. )
  16. func TestSlotInfoPage(t *testing.T) {
  17. r := file.NewRecord(123, make([]byte, 20))
  18. // Make sure the record has a correct magic
  19. view.NewPageView(r, view.TypeDataPage)
  20. si := NewSlotInfoPage(r)
  21. si.SetSlotInfo(2, 99, 45)
  22. if si.SlotInfoOffset(2) != 45 {
  23. t.Error("Unexpected offset read back")
  24. }
  25. if si.SlotInfoRecord(2) != 99 {
  26. t.Error("Unexpected record read back")
  27. }
  28. }