From ad85ea17bb1bd4a459b1ab43e491cce04e84cc29 Mon Sep 17 00:00:00 2001 From: Inteon <42113979+inteon@users.noreply.github.com> Date: Fri, 29 Oct 2021 15:15:43 +0200 Subject: [PATCH] add test for issue nr.58 Signed-off-by: Inteon <42113979+inteon@users.noreply.github.com> --- yaml_test.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/yaml_test.go b/yaml_test.go index e8e19cc..941fde2 100644 --- a/yaml_test.go +++ b/yaml_test.go @@ -495,6 +495,30 @@ func TestUnmarshal(t *testing.T) { }, }, + // BUG: type info gets lost (#58) + "decode embeded struct and cast integer to string": { + encoded: []byte("a: 11\nb: testB"), + decodeInto: new(UnmarshalEmbedStruct), + decoded: UnmarshalEmbedStruct{ + UnmarshalStruct: UnmarshalStruct{ + A: "11", + }, + B: "testB", + }, + err: fatalErrorsType, + }, + "decode embeded structpointer and cast integer to string": { + encoded: []byte("a: 11\nb: testB"), + decodeInto: new(UnmarshalEmbedStructPointer), + decoded: UnmarshalEmbedStructPointer{ + UnmarshalStruct: &UnmarshalStruct{ + A: "11", + }, + B: "testB", + }, + err: fatalErrorsType, + }, + // decoding into incompatible type "decode into stringmap with incompatible type": { encoded: []byte("a:\n a:\n a: 3"),