summaryrefslogtreecommitdiff
path: root/spew/common_test.go
diff options
context:
space:
mode:
authorDave Collins <[email protected]>2013-11-14 22:22:17 -0600
committerDave Collins <[email protected]>2013-11-14 22:22:17 -0600
commit92b7ef315aff940fca77446da2fab578c3cd7651 (patch)
treea3a13ead9fd111e610790e0a5b352583b0181305 /spew/common_test.go
parent3b4a2055ceb3d3f007cad35f3766431c93ef457d (diff)
Add additional tests for new sortValues code.
This brings the test coverage back to 100%.
Diffstat (limited to 'spew/common_test.go')
-rw-r--r--spew/common_test.go35
1 files changed, 31 insertions, 4 deletions
diff --git a/spew/common_test.go b/spew/common_test.go
index 0a534ac..c27f798 100644
--- a/spew/common_test.go
+++ b/spew/common_test.go
@@ -121,26 +121,53 @@ func TestSortValues(t *testing.T) {
a := v("a")
b := v("b")
c := v("c")
+ embedA := v(embed{"a"})
+ embedB := v(embed{"b"})
+ embedC := v(embed{"c"})
tests := []struct {
input []reflect.Value
expected []reflect.Value
}{
+ // No values.
+ {
+ []reflect.Value{},
+ []reflect.Value{},
+ },
+ // Bools.
+ {
+ []reflect.Value{v(false), v(true), v(false)},
+ []reflect.Value{v(false), v(false), v(true)},
+ },
+ // Ints.
{
[]reflect.Value{v(2), v(1), v(3)},
[]reflect.Value{v(1), v(2), v(3)},
},
+ // Uints.
{
- []reflect.Value{v(2.), v(1.), v(3.)},
- []reflect.Value{v(1.), v(2.), v(3.)},
+ []reflect.Value{v(uint8(2)), v(uint8(1)), v(uint8(3))},
+ []reflect.Value{v(uint8(1)), v(uint8(2)), v(uint8(3))},
},
+ // Floats.
{
- []reflect.Value{v(false), v(true), v(false)},
- []reflect.Value{v(false), v(false), v(true)},
+ []reflect.Value{v(2.0), v(1.0), v(3.0)},
+ []reflect.Value{v(1.0), v(2.0), v(3.0)},
},
+ // Strings.
{
[]reflect.Value{b, a, c},
[]reflect.Value{a, b, c},
},
+ // Uintptrs.
+ {
+ []reflect.Value{v(uintptr(2)), v(uintptr(1)), v(uintptr(3))},
+ []reflect.Value{v(uintptr(1)), v(uintptr(2)), v(uintptr(3))},
+ },
+ // Invalid.
+ {
+ []reflect.Value{embedB, embedA, embedC},
+ []reflect.Value{embedB, embedA, embedC},
+ },
}
for _, test := range tests {
spew.SortValues(test.input)