Fixed format types

This commit is contained in:
CrushedPixel 2018-03-28 15:14:32 +02:00 committed by Sam Woodard
parent ccac636b4b
commit 87c6b8e5b5
2 changed files with 6 additions and 6 deletions

View File

@ -254,10 +254,10 @@ func unmarshalNode(data *Node, model reflect.Value, included *map[string]*Node)
} }
// As a final catch-all, ensure types line up to avoid a runtime panic. // As a final catch-all, ensure types line up to avoid a runtime panic.
if fieldValue.Kind() != v.Kind() { if fieldValue.Kind() != value.Kind() {
return ErrInvalidType return ErrInvalidType
} }
assignValue(fieldValue, reflect.ValueOf(val)) assignValue(fieldValue, value)
} else if annotation == annotationRelation { } else if annotation == annotationRelation {
isSlice := fieldValue.Type().Kind() == reflect.Slice isSlice := fieldValue.Type().Kind() == reflect.Slice

View File

@ -799,17 +799,17 @@ func TestUnmarshalCustomTypeAttributes(t *testing.T) {
} }
if expected, actual := customInt, customAttributeTypes.Int; expected != actual { if expected, actual := customInt, customAttributeTypes.Int; expected != actual {
t.Fatalf("Was expecting custom int to be `%s`, got `%s`", expected, actual) t.Fatalf("Was expecting custom int to be `%d`, got `%d`", expected, actual)
} }
if expected, actual := customInt, *customAttributeTypes.IntPtr; expected != actual { if expected, actual := customInt, *customAttributeTypes.IntPtr; expected != actual {
t.Fatalf("Was expecting custom int pointer to be `%s`, got `%s`", expected, actual) t.Fatalf("Was expecting custom int pointer to be `%d`, got `%d`", expected, actual)
} }
if customAttributeTypes.IntPtrNull != nil { if customAttributeTypes.IntPtrNull != nil {
t.Fatalf("Was expecting custom int pointer to be <nil>, got `%s`", customAttributeTypes.IntPtrNull) t.Fatalf("Was expecting custom int pointer to be <nil>, got `%d`", customAttributeTypes.IntPtrNull)
} }
if expected, actual := customFloat, customAttributeTypes.Float; expected != actual { if expected, actual := customFloat, customAttributeTypes.Float; expected != actual {
t.Fatalf("Was expecting custom float to be `%s`, got `%s`", expected, actual) t.Fatalf("Was expecting custom float to be `%f`, got `%f`", expected, actual)
} }
if expected, actual := customString, customAttributeTypes.String; expected != actual { if expected, actual := customString, customAttributeTypes.String; expected != actual {
t.Fatalf("Was expecting custom string to be `%s`, got `%s`", expected, actual) t.Fatalf("Was expecting custom string to be `%s`, got `%s`", expected, actual)