Add test for PR #9
diff --git a/mapstructure.go b/mapstructure.go
index c46fe2b..a61df0b 100644
--- a/mapstructure.go
+++ b/mapstructure.go
@@ -515,7 +515,8 @@
if fieldType.Anonymous {
fieldKind := fieldType.Type.Kind()
if fieldKind != reflect.Struct {
- errors = appendErrors(errors, fmt.Errorf("%s: unsupported type: %s", fieldType.Name, fieldKind))
+ errors = appendErrors(errors,
+ fmt.Errorf("%s: unsupported type: %s", fieldType.Name, fieldKind))
continue
}
diff --git a/mapstructure_test.go b/mapstructure_test.go
index 3ac1dda..53aa5f8 100644
--- a/mapstructure_test.go
+++ b/mapstructure_test.go
@@ -22,6 +22,11 @@
Vunique string
}
+type EmbeddedPointer struct {
+ *Basic
+ Vunique string
+}
+
type EmbeddedSquash struct {
Basic `mapstructure:",squash"`
Vunique string
@@ -173,6 +178,24 @@
}
}
+func TestDecode_EmbeddedPointer(t *testing.T) {
+ t.Parallel()
+
+ input := map[string]interface{}{
+ "vstring": "foo",
+ "Basic": map[string]interface{}{
+ "vstring": "innerfoo",
+ },
+ "vunique": "bar",
+ }
+
+ var result EmbeddedPointer
+ err := Decode(input, &result)
+ if err == nil {
+ t.Fatal("should get error")
+ }
+}
+
func TestDecode_EmbeddedSquash(t *testing.T) {
t.Parallel()