shad-go/illegal/field_test.go
Albert Skalt 11277ded5b Add test
2023-04-23 14:52:12 +04:00

27 lines
495 B
Go

package illegal_test
import (
"testing"
"github.com/stretchr/testify/assert"
"gitlab.com/slon/shad-go/illegal"
"gitlab.com/slon/shad-go/illegal/internal"
)
func TestIllegalField(t *testing.T) {
var s internal.Struct
illegal.SetPrivateField(&s, "a", 10)
illegal.SetPrivateField(&s, "b", "foo")
assert.Equal(t, "10 foo", s.String())
}
func TestIllegalWrongFieldType(t *testing.T) {
var s internal.Struct
assert.Panics(t, func() {
illegal.SetPrivateField(&s, "a", "1234")
})
}