transpage_test.go 833 B

12345678910111213141516171819202122232425262728293031323334353637383940
  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 TestTransPage(t *testing.T) {
  17. r := file.NewRecord(123, make([]byte, 44))
  18. testCheckTransPageMagicPanic(t, r)
  19. // Make sure the record has a correct magic
  20. view.NewPageView(r, view.TypeTranslationPage)
  21. NewTransPage(r)
  22. }
  23. func testCheckTransPageMagicPanic(t *testing.T, r *file.Record) {
  24. defer func() {
  25. if r := recover(); r == nil {
  26. t.Error("Checking magic should fail.")
  27. }
  28. }()
  29. checkTransPageMagic(r)
  30. }