Files
excelConverter/pkg/set/set_test.go
Andreas Schröpfer cc6e58acd9 basic conf for loader
2021-02-27 20:09:29 +01:00

31 lines
615 B
Go

package set
import "testing"
func TestField(t *testing.T) {
input := struct {
MyString string
MyInt int
MyBool bool
}{}
value := "abc"
Field(&input, "MyString", value)
if input.MyString != value {
t.Errorf("got: %s; want: %s", input.MyString, value)
}
vInt := 2
Field(&input, "MyInt", vInt)
if input.MyInt != vInt {
t.Errorf("MyInt: %d, want: %d", input.MyInt, vInt)
}
err := Field(&input, "MyInt", "vInt")
if err == nil {
t.Error("expect error, when wrong value-Type")
}
err = Field(&input, "NoField", "jjj")
if err == nil {
t.Error("expect error, when field not exists")
}
}