38 lines
654 B
Go
38 lines
654 B
Go
package chunk_test
|
||
|
||
import (
|
||
"fmt"
|
||
"testing"
|
||
|
||
"github.com/stretchr/testify/require"
|
||
"sectorinf.com/emilis/flabk/pkg/ld/internal/parse/chunk"
|
||
)
|
||
|
||
func TestSpace(t *testing.T) {
|
||
that := require.New(t)
|
||
ch := chunk.New([]byte(" hello world"))
|
||
that.True(ch.AtSpace())
|
||
}
|
||
|
||
func TestParseMap(t *testing.T) {
|
||
type Hello struct {
|
||
Hello string
|
||
}
|
||
ch := chunk.New([]byte(`"Hello": "world"`))
|
||
h, err := chunk.ParseMap[Hello](ch)(Hello{})
|
||
if err != nil {
|
||
panic(err)
|
||
}
|
||
fmt.Println(h)
|
||
}
|
||
|
||
func TestChild(t *testing.T) {
|
||
type Hello struct {
|
||
Hello string
|
||
}
|
||
ch := chunk.New([]byte(`"Hello": "world"`))
|
||
child := ch.Child(5, 10)
|
||
|
||
fmt.Println(child)
|
||
}
|