From d4b9b2a00813ef6f28f75a685bd868aab4609ec4 Mon Sep 17 00:00:00 2001 From: Alex Flint Date: Mon, 19 Apr 2021 19:23:08 -0700 Subject: [PATCH] push coverage up even more --- sequence_test.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/sequence_test.go b/sequence_test.go index dd866c6..fde3e3a 100644 --- a/sequence_test.go +++ b/sequence_test.go @@ -127,3 +127,26 @@ func TestSetMapMalformed(t *testing.T) { err := setMap(reflect.ValueOf(&m).Elem(), entries, true) assert.Error(t, err) } + +func TestSetSliceOrMapErrors(t *testing.T) { + var err error + var dest reflect.Value + + // converting a slice to a reflect.Value in this way will make it read only + var cannotSet []int + dest = reflect.ValueOf(cannotSet) + err = setSliceOrMap(dest, nil, false) + assert.Error(t, err) + + // check what happens when we pass in something that is not a slice or a map + var notSliceOrMap string + dest = reflect.ValueOf(¬SliceOrMap).Elem() + err = setSliceOrMap(dest, nil, false) + assert.Error(t, err) + + // check what happens when we pass in a pointer to something that is not a slice or a map + var stringPtr *string + dest = reflect.ValueOf(&stringPtr).Elem() + err = setSliceOrMap(dest, nil, false) + assert.Error(t, err) +}