push code coverage up
This commit is contained in:
parent
bb4e7fd4b0
commit
0100c0a411
|
@ -16,7 +16,7 @@ func TestSetSliceWithoutClearing(t *testing.T) {
|
||||||
assert.Equal(t, []int{10, 1, 2, 3}, xs)
|
assert.Equal(t, []int{10, 1, 2, 3}, xs)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSetSliceWithClear(t *testing.T) {
|
func TestSetSliceAfterClearing(t *testing.T) {
|
||||||
xs := []int{100}
|
xs := []int{100}
|
||||||
entries := []string{"1", "2", "3"}
|
entries := []string{"1", "2", "3"}
|
||||||
err := setSlice(reflect.ValueOf(&xs).Elem(), entries, true)
|
err := setSlice(reflect.ValueOf(&xs).Elem(), entries, true)
|
||||||
|
@ -24,6 +24,13 @@ func TestSetSliceWithClear(t *testing.T) {
|
||||||
assert.Equal(t, []int{1, 2, 3}, xs)
|
assert.Equal(t, []int{1, 2, 3}, xs)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestSetSliceInvalid(t *testing.T) {
|
||||||
|
xs := []int{100}
|
||||||
|
entries := []string{"invalid"}
|
||||||
|
err := setSlice(reflect.ValueOf(&xs).Elem(), entries, true)
|
||||||
|
assert.Error(t, err)
|
||||||
|
}
|
||||||
|
|
||||||
func TestSetSlicePtr(t *testing.T) {
|
func TestSetSlicePtr(t *testing.T) {
|
||||||
var xs []*int
|
var xs []*int
|
||||||
entries := []string{"1", "2", "3"}
|
entries := []string{"1", "2", "3"}
|
||||||
|
@ -58,7 +65,7 @@ func TestSetMapWithoutClearing(t *testing.T) {
|
||||||
assert.Equal(t, 10, m["foo"])
|
assert.Equal(t, 10, m["foo"])
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSetMapWithClear(t *testing.T) {
|
func TestSetMapAfterClearing(t *testing.T) {
|
||||||
m := map[string]int{"foo": 10}
|
m := map[string]int{"foo": 10}
|
||||||
entries := []string{"a=1", "b=2"}
|
entries := []string{"a=1", "b=2"}
|
||||||
err := setMap(reflect.ValueOf(&m).Elem(), entries, true)
|
err := setMap(reflect.ValueOf(&m).Elem(), entries, true)
|
||||||
|
@ -68,6 +75,25 @@ func TestSetMapWithClear(t *testing.T) {
|
||||||
assert.Equal(t, 2, m["b"])
|
assert.Equal(t, 2, m["b"])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestSetMapWithKeyPointer(t *testing.T) {
|
||||||
|
// textUnmarshaler is a struct that captures the length of the string passed to it
|
||||||
|
var m map[*string]int
|
||||||
|
entries := []string{"abc=123"}
|
||||||
|
err := setMap(reflect.ValueOf(&m).Elem(), entries, true)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Len(t, m, 1)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestSetMapWithValuePointer(t *testing.T) {
|
||||||
|
// textUnmarshaler is a struct that captures the length of the string passed to it
|
||||||
|
var m map[string]*int
|
||||||
|
entries := []string{"abc=123"}
|
||||||
|
err := setMap(reflect.ValueOf(&m).Elem(), entries, true)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Len(t, m, 1)
|
||||||
|
assert.Equal(t, 123, *m["abc"])
|
||||||
|
}
|
||||||
|
|
||||||
func TestSetMapTextUnmarshaller(t *testing.T) {
|
func TestSetMapTextUnmarshaller(t *testing.T) {
|
||||||
// textUnmarshaler is a struct that captures the length of the string passed to it
|
// textUnmarshaler is a struct that captures the length of the string passed to it
|
||||||
var m map[textUnmarshaler]*textUnmarshaler
|
var m map[textUnmarshaler]*textUnmarshaler
|
||||||
|
@ -80,6 +106,20 @@ func TestSetMapTextUnmarshaller(t *testing.T) {
|
||||||
assert.Equal(t, &textUnmarshaler{1}, m[textUnmarshaler{3}])
|
assert.Equal(t, &textUnmarshaler{1}, m[textUnmarshaler{3}])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestSetMapInvalidKey(t *testing.T) {
|
||||||
|
var m map[int]int
|
||||||
|
entries := []string{"invalid=123"}
|
||||||
|
err := setMap(reflect.ValueOf(&m).Elem(), entries, true)
|
||||||
|
assert.Error(t, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestSetMapInvalidValue(t *testing.T) {
|
||||||
|
var m map[int]int
|
||||||
|
entries := []string{"123=invalid"}
|
||||||
|
err := setMap(reflect.ValueOf(&m).Elem(), entries, true)
|
||||||
|
assert.Error(t, err)
|
||||||
|
}
|
||||||
|
|
||||||
func TestSetMapMalformed(t *testing.T) {
|
func TestSetMapMalformed(t *testing.T) {
|
||||||
// textUnmarshaler is a struct that captures the length of the string passed to it
|
// textUnmarshaler is a struct that captures the length of the string passed to it
|
||||||
var m map[string]string
|
var m map[string]string
|
||||||
|
|
Loading…
Reference in New Issue