Package list golang-github-imdario-mergo / c6727c3f-0907-4f02-894b-b681425735d5/upstream issue136_test.go
c6727c3f-0907-4f02-894b-b681425735d5/upstream

Tree @c6727c3f-0907-4f02-894b-b681425735d5/upstream (Download .tar.gz)

issue136_test.go @c6727c3f-0907-4f02-894b-b681425735d5/upstreamraw · history · blame

package mergo_test

import (
	"testing"

	"github.com/imdario/mergo"
)

type embeddedTestA struct {
	Name string
	Age  uint8
}

type embeddedTestB struct {
	embeddedTestA
	Address string
}

func TestMergeEmbedded(t *testing.T) {
	var (
		err error
		a   = &embeddedTestA{
			"Suwon", 16,
		}
		b = &embeddedTestB{}
	)

	if err := mergo.Merge(&b.embeddedTestA, *a); err != nil {
		t.Error(err)
	}

	if b.Name != "Suwon" {
		t.Errorf("%v %v", b.Name, err)
	}
}