Add StructSetValue func
This commit is contained in:
@@ -4,6 +4,26 @@ import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestStructSetValue(t *testing.T) {
|
||||
type O struct {
|
||||
Name string
|
||||
Age int
|
||||
Active bool
|
||||
}
|
||||
|
||||
o := &O{
|
||||
Name: "Nick",
|
||||
Age: 15,
|
||||
Active: true,
|
||||
}
|
||||
|
||||
StructSetValue(o, "Name", "George")
|
||||
|
||||
if o.Name != "George" {
|
||||
t.Fatalf("Name should have been George not %s", o.Name)
|
||||
}
|
||||
}
|
||||
|
||||
func TestStructToStruct(t *testing.T) {
|
||||
type O struct {
|
||||
Name string
|
||||
|
||||
Reference in New Issue
Block a user