File: structs_test.go

package info (click to toggle)
badger 4.8.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,672 kB
  • sloc: sh: 132; makefile: 61
file content (26 lines) | stat: -rw-r--r-- 670 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
/*
 * SPDX-FileCopyrightText: © Hypermode Inc. <hello@hypermode.com>
 * SPDX-License-Identifier: Apache-2.0
 */

package badger

import (
	"math"
	"reflect"
	"testing"

	"github.com/stretchr/testify/require"
)

// Regression test for github.com/hypermodeinc/badger/pull/1800
func TestLargeEncode(t *testing.T) {
	var headerEnc [maxHeaderSize]byte
	h := header{math.MaxUint32, math.MaxUint32, math.MaxUint64, math.MaxUint8, math.MaxUint8}
	require.NotPanics(t, func() { _ = h.Encode(headerEnc[:]) })
}

func TestNumFieldsHeader(t *testing.T) {
	// maxHeaderSize must correspond with any changes made to header
	require.Equal(t, 5, reflect.TypeOf(header{}).NumField())
}