db/pkg/headers/headers_test.go
2022-04-17 13:38:45 +03:00

33 lines
646 B
Go

package headers
import (
"crypto/rand"
"reflect"
"testing"
)
func TestHeaders_Generate(t *testing.T) {
initialHeaders := Headers{
HeaderString: []byte(HeaderString),
PageSize: uint64(256 ^ 2),
DBVersion: uint16(1),
WAL: true,
Commit: make([]byte, CommitDataLength),
}
_, err := rand.Read(initialHeaders.Commit[:CommitDataLength])
if err != nil {
t.Error("Failed to generate random string")
}
output := initialHeaders.Generate()
parsedHeaders := Headers{}
parsedHeaders.Parse(output, 0)
if !reflect.DeepEqual(initialHeaders, parsedHeaders) {
t.Error("deepequal failed, headers are not identical.")
}
}