update readme & add header_test sample cmd

This commit is contained in:
zutto 2022-04-17 01:33:34 +03:00
parent a5e92623ce
commit 094afdb15a
3 changed files with 30 additions and 2 deletions

View file

@ -1,3 +1,3 @@
# Project in progress. # Project in progress.
[Click here for more](https://zutto.fi/posts/data-structure/) [Click here for more](https://zutto.fi/posts/db/headers/)

View file

@ -0,0 +1,27 @@
package main
import (
"crypto/rand"
"fmt"
"git.zutto.fi/zutto/db/pkg/headers"
)
func main() {
h := headers.Headers{
HeaderString: []byte(headers.HeaderString),
PageSize: uint64(256 ^ 2),
DBVersion: uint16(1),
WAL: false,
Commit: make([]byte, headers.CommitDataLength),
}
//generate random string for the commit..
_, err := rand.Read(h.Commit[:headers.CommitDataLength])
if err != nil {
fmt.Errorf("Failed to generate random string")
}
fmt.Printf("%c", h.Generate())
}

View file

@ -2,6 +2,7 @@ package headers
import ( import (
"crypto/rand" "crypto/rand"
"fmt"
"reflect" "reflect"
"testing" "testing"
) )
@ -23,7 +24,7 @@ func TestHeaders_Generate(t *testing.T) {
} }
output := h.Generate() output := h.Generate()
fmt.Printf("%c", output)
h2 := Headers{} h2 := Headers{}
h2.Parse(output, 0) h2.Parse(output, 0)