From fde64662ce56957ed21c47d12ea3d993fa1f3b3e Mon Sep 17 00:00:00 2001 From: zutto Date: Sun, 17 Apr 2022 13:38:45 +0300 Subject: [PATCH] make the test more clear --- pkg/headers/headers_test.go | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/pkg/headers/headers_test.go b/pkg/headers/headers_test.go index 5e55a05..2fa0dae 100644 --- a/pkg/headers/headers_test.go +++ b/pkg/headers/headers_test.go @@ -2,14 +2,13 @@ package headers import ( "crypto/rand" - "fmt" "reflect" "testing" ) func TestHeaders_Generate(t *testing.T) { - h := Headers{ + initialHeaders := Headers{ HeaderString: []byte(HeaderString), PageSize: uint64(256 ^ 2), DBVersion: uint16(1), @@ -18,17 +17,17 @@ func TestHeaders_Generate(t *testing.T) { Commit: make([]byte, CommitDataLength), } - _, err := rand.Read(h.Commit[:CommitDataLength]) + _, err := rand.Read(initialHeaders.Commit[:CommitDataLength]) if err != nil { t.Error("Failed to generate random string") } - output := h.Generate() - fmt.Printf("%c", output) - h2 := Headers{} - h2.Parse(output, 0) + output := initialHeaders.Generate() - if !reflect.DeepEqual(h, h2) { - t.Error("deepequal failed") + parsedHeaders := Headers{} + parsedHeaders.Parse(output, 0) + + if !reflect.DeepEqual(initialHeaders, parsedHeaders) { + t.Error("deepequal failed, headers are not identical.") } }