Skip to content

Commit

Permalink
add test case
Browse files Browse the repository at this point in the history
Signed-off-by: Davanum Srinivas <davanum@gmail.com>
  • Loading branch information
dims committed Dec 18, 2021
1 parent 115f500 commit ba7e1ea
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions klog_test.go
Expand Up @@ -1063,8 +1063,20 @@ func TestErrorS(t *testing.T) {
}
}

// point conforms to fmt.Stringer interface as it implements the String() method
type point struct {
x int
y int
}

// we now have a value receiver
func (p point) String() string {
return fmt.Sprintf("x=%d, y=%d", p.x, p.y)
}

// Test that kvListFormat works as advertised.
func TestKvListFormat(t *testing.T) {
var emptyPoint *point
var testKVList = []struct {
keysValues []interface{}
want string
Expand Down Expand Up @@ -1159,6 +1171,10 @@ No whitespace.`,
})},
want: " pods=[kube-system/kube-dns mi-conf]",
},
{
keysValues: []interface{}{"point-1", point{100, 200}, "point-2", emptyPoint},
want: " point-1=\"x=100, y=200\" point-2=\"nil\"",
},
}

for _, d := range testKVList {
Expand Down

0 comments on commit ba7e1ea

Please sign in to comment.