Package list golang-github-imdario-mergo / bd63fc79-05f6-4175-a57a-a1e9f503f8a2/main issue136_test.go
bd63fc79-05f6-4175-a57a-a1e9f503f8a2/main

Tree @bd63fc79-05f6-4175-a57a-a1e9f503f8a2/main (Download .tar.gz)

issue136_test.go @bd63fc79-05f6-4175-a57a-a1e9f503f8a2/mainraw · 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)
	}
}