flabk/pkg/asld/unmarshal_test.go

40 lines
725 B
Go

package asld_test
import (
"encoding/json"
"testing"
"git.sectorinf.com/emilis/asflab/pkg/asld"
"git.sectorinf.com/emilis/asflab/pkg/epk"
"github.com/stretchr/testify/require"
)
type testObj struct {
String string `asld:"string" json:"string"`
}
func TestUnmarshal(t *testing.T) {
tests := map[string]struct {
obj testObj
errCheck epk.ErrorTest
}{
"string children": {
obj: testObj{
"hello",
},
},
}
for name, test := range tests {
test := test
t.Run(name, func(tt *testing.T) {
that := require.New(tt)
objJSON, err := json.Marshal(test.obj)
that.NoError(err)
result, err := asld.Unmarshal[testObj](objJSON)
that.NoError(err)
that.Equal(test.obj, result)
})
}
}