Added types tests
All checks were successful
/ test (push) Successful in 20s

This commit is contained in:
Eduard Urbach 2025-07-03 19:46:23 +02:00
parent 0eaeb726b9
commit ba2314db4a
Signed by: akyoto
GPG key ID: 49226B848C78F6C8
2 changed files with 36 additions and 0 deletions

View file

@ -28,6 +28,7 @@ func TestParse(t *testing.T) {
{"float", types.Float},
{"float64", types.Float64},
{"float32", types.Float32},
{"string", types.String},
{"any", types.Any},
{"*any", types.AnyPointer},
{"*byte", &types.Pointer{To: types.Byte}},

35
src/types/Struct_test.go Normal file
View file

@ -0,0 +1,35 @@
package types_test
import (
"testing"
"git.urbach.dev/cli/q/src/types"
"git.urbach.dev/go/assert"
)
func TestStruct(t *testing.T) {
point := types.NewStruct("math", "Point")
x := &types.Field{
Name: "x",
Type: types.Int,
Index: 0,
Offset: 0,
}
y := &types.Field{
Name: "y",
Type: types.Int,
Index: 1,
Offset: 8,
}
point.AddField(x)
point.AddField(y)
assert.Equal(t, x.String(), "x")
assert.Equal(t, y.String(), "y")
assert.Equal(t, point.FieldByName("x"), x)
assert.Equal(t, point.FieldByName("y"), y)
assert.Nil(t, point.FieldByName("invalid"))
}