mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-22 19:31:44 +00:00
Update spew to support better map key sorting.
This commit is contained in:
parent
fce3e5a2bb
commit
942563fda1
2
Godeps/Godeps.json
generated
2
Godeps/Godeps.json
generated
@ -89,7 +89,7 @@
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/davecgh/go-spew/spew",
|
||||
"Rev": "1aaf839fb07e099361e445273993ccd9adc21b07"
|
||||
"Rev": "3e6e67c4dcea3ac2f25fd4731abc0e1deaf36216"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/daviddengcn/go-colortext",
|
||||
|
119
Godeps/_workspace/src/github.com/davecgh/go-spew/spew/common.go
generated
vendored
119
Godeps/_workspace/src/github.com/davecgh/go-spew/spew/common.go
generated
vendored
@ -17,6 +17,7 @@
|
||||
package spew
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io"
|
||||
"reflect"
|
||||
@ -325,7 +326,61 @@ func printHexPtr(w io.Writer, p uintptr) {
|
||||
// valuesSorter implements sort.Interface to allow a slice of reflect.Value
|
||||
// elements to be sorted.
|
||||
type valuesSorter struct {
|
||||
values []reflect.Value
|
||||
values []reflect.Value
|
||||
strings []string // either nil or same len and values
|
||||
cs *ConfigState
|
||||
}
|
||||
|
||||
// newValuesSorter initializes a valuesSorter instance, which holds a set of
|
||||
// surrogate keys on which the data should be sorted. It uses flags in
|
||||
// ConfigState to decide if and how to populate those surrogate keys.
|
||||
func newValuesSorter(values []reflect.Value, cs *ConfigState) sort.Interface {
|
||||
vs := &valuesSorter{values: values, cs: cs}
|
||||
if canSortSimply(vs.values[0].Kind()) {
|
||||
return vs
|
||||
}
|
||||
if !cs.DisableMethods {
|
||||
vs.strings = make([]string, len(values))
|
||||
for i := range vs.values {
|
||||
b := bytes.Buffer{}
|
||||
if !handleMethods(cs, &b, vs.values[i]) {
|
||||
vs.strings = nil
|
||||
break
|
||||
}
|
||||
vs.strings[i] = b.String()
|
||||
}
|
||||
}
|
||||
if vs.strings == nil && cs.SpewKeys {
|
||||
vs.strings = make([]string, len(values))
|
||||
for i := range vs.values {
|
||||
vs.strings[i] = Sprintf("%#v", vs.values[i].Interface())
|
||||
}
|
||||
}
|
||||
return vs
|
||||
}
|
||||
|
||||
// canSortSimply tests whether a reflect.Kind is a primitive that can be sorted
|
||||
// directly, or whether it should be considered for sorting by surrogate keys
|
||||
// (if the ConfigState allows it).
|
||||
func canSortSimply(kind reflect.Kind) bool {
|
||||
// This switch parallels valueSortLess, except for the default case.
|
||||
switch kind {
|
||||
case reflect.Bool:
|
||||
return true
|
||||
case reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Int:
|
||||
return true
|
||||
case reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uint:
|
||||
return true
|
||||
case reflect.Float32, reflect.Float64:
|
||||
return true
|
||||
case reflect.String:
|
||||
return true
|
||||
case reflect.Uintptr:
|
||||
return true
|
||||
case reflect.Array:
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// Len returns the number of values in the slice. It is part of the
|
||||
@ -338,34 +393,58 @@ func (s *valuesSorter) Len() int {
|
||||
// sort.Interface implementation.
|
||||
func (s *valuesSorter) Swap(i, j int) {
|
||||
s.values[i], s.values[j] = s.values[j], s.values[i]
|
||||
if s.strings != nil {
|
||||
s.strings[i], s.strings[j] = s.strings[j], s.strings[i]
|
||||
}
|
||||
}
|
||||
|
||||
// valueSortLess returns whether the first value should sort before the second
|
||||
// value. It is used by valueSorter.Less as part of the sort.Interface
|
||||
// implementation.
|
||||
func valueSortLess(a, b reflect.Value) bool {
|
||||
switch a.Kind() {
|
||||
case reflect.Bool:
|
||||
return !a.Bool() && b.Bool()
|
||||
case reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Int:
|
||||
return a.Int() < b.Int()
|
||||
case reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uint:
|
||||
return a.Uint() < b.Uint()
|
||||
case reflect.Float32, reflect.Float64:
|
||||
return a.Float() < b.Float()
|
||||
case reflect.String:
|
||||
return a.String() < b.String()
|
||||
case reflect.Uintptr:
|
||||
return a.Uint() < b.Uint()
|
||||
case reflect.Array:
|
||||
// Compare the contents of both arrays.
|
||||
l := a.Len()
|
||||
for i := 0; i < l; i++ {
|
||||
av := a.Index(i)
|
||||
bv := b.Index(i)
|
||||
if av.Interface() == bv.Interface() {
|
||||
continue
|
||||
}
|
||||
return valueSortLess(av, bv)
|
||||
}
|
||||
}
|
||||
return a.String() < b.String()
|
||||
}
|
||||
|
||||
// Less returns whether the value at index i should sort before the
|
||||
// value at index j. It is part of the sort.Interface implementation.
|
||||
func (s *valuesSorter) Less(i, j int) bool {
|
||||
switch s.values[i].Kind() {
|
||||
case reflect.Bool:
|
||||
return !s.values[i].Bool() && s.values[j].Bool()
|
||||
case reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Int:
|
||||
return s.values[i].Int() < s.values[j].Int()
|
||||
case reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uint:
|
||||
return s.values[i].Uint() < s.values[j].Uint()
|
||||
case reflect.Float32, reflect.Float64:
|
||||
return s.values[i].Float() < s.values[j].Float()
|
||||
case reflect.String:
|
||||
return s.values[i].String() < s.values[j].String()
|
||||
case reflect.Uintptr:
|
||||
return s.values[i].Uint() < s.values[j].Uint()
|
||||
if s.strings == nil {
|
||||
return valueSortLess(s.values[i], s.values[j])
|
||||
}
|
||||
return s.values[i].String() < s.values[j].String()
|
||||
return s.strings[i] < s.strings[j]
|
||||
}
|
||||
|
||||
// sortValues is a generic sort function for native types: int, uint, bool,
|
||||
// string and uintptr. Other inputs are sorted according to their
|
||||
// Value.String() value to ensure display stability.
|
||||
func sortValues(values []reflect.Value) {
|
||||
// sortValues is a sort function that handles both native types and any type that
|
||||
// can be converted to error or Stringer. Other inputs are sorted according to
|
||||
// their Value.String() value to ensure display stability.
|
||||
func sortValues(values []reflect.Value, cs *ConfigState) {
|
||||
if len(values) == 0 {
|
||||
return
|
||||
}
|
||||
sort.Sort(&valuesSorter{values})
|
||||
sort.Sort(newValuesSorter(values, cs))
|
||||
}
|
||||
|
146
Godeps/_workspace/src/github.com/davecgh/go-spew/spew/common_test.go
generated
vendored
146
Godeps/_workspace/src/github.com/davecgh/go-spew/spew/common_test.go
generated
vendored
@ -18,9 +18,10 @@ package spew_test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/davecgh/go-spew/spew"
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/davecgh/go-spew/spew"
|
||||
)
|
||||
|
||||
// custom type to test Stinger interface on non-pointer receiver.
|
||||
@ -113,9 +114,24 @@ func testFailed(result string, wants []string) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// TestSortValues ensures the sort functionality for relect.Value based sorting
|
||||
// works as intended.
|
||||
func TestSortValues(t *testing.T) {
|
||||
type sortableStruct struct {
|
||||
x int
|
||||
}
|
||||
|
||||
func (ss sortableStruct) String() string {
|
||||
return fmt.Sprintf("ss.%d", ss.x)
|
||||
}
|
||||
|
||||
type unsortableStruct struct {
|
||||
x int
|
||||
}
|
||||
|
||||
type sortTestCase struct {
|
||||
input []reflect.Value
|
||||
expected []reflect.Value
|
||||
}
|
||||
|
||||
func helpTestSortValues(tests []sortTestCase, cs *spew.ConfigState, t *testing.T) {
|
||||
getInterfaces := func(values []reflect.Value) []interface{} {
|
||||
interfaces := []interface{}{}
|
||||
for _, v := range values {
|
||||
@ -124,6 +140,23 @@ func TestSortValues(t *testing.T) {
|
||||
return interfaces
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
spew.SortValues(test.input, cs)
|
||||
// reflect.DeepEqual cannot really make sense of reflect.Value,
|
||||
// probably because of all the pointer tricks. For instance,
|
||||
// v(2.0) != v(2.0) on a 32-bits system. Turn them into interface{}
|
||||
// instead.
|
||||
input := getInterfaces(test.input)
|
||||
expected := getInterfaces(test.expected)
|
||||
if !reflect.DeepEqual(input, expected) {
|
||||
t.Errorf("Sort mismatch:\n %v != %v", input, expected)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TestSortValues ensures the sort functionality for relect.Value based sorting
|
||||
// works as intended.
|
||||
func TestSortValues(t *testing.T) {
|
||||
v := reflect.ValueOf
|
||||
|
||||
a := v("a")
|
||||
@ -132,10 +165,7 @@ func TestSortValues(t *testing.T) {
|
||||
embedA := v(embed{"a"})
|
||||
embedB := v(embed{"b"})
|
||||
embedC := v(embed{"c"})
|
||||
tests := []struct {
|
||||
input []reflect.Value
|
||||
expected []reflect.Value
|
||||
}{
|
||||
tests := []sortTestCase{
|
||||
// No values.
|
||||
{
|
||||
[]reflect.Value{},
|
||||
@ -166,27 +196,103 @@ func TestSortValues(t *testing.T) {
|
||||
[]reflect.Value{b, a, c},
|
||||
[]reflect.Value{a, b, c},
|
||||
},
|
||||
// Array
|
||||
{
|
||||
[]reflect.Value{v([3]int{3, 2, 1}), v([3]int{1, 3, 2}), v([3]int{1, 2, 3})},
|
||||
[]reflect.Value{v([3]int{1, 2, 3}), v([3]int{1, 3, 2}), v([3]int{3, 2, 1})},
|
||||
},
|
||||
// Uintptrs.
|
||||
{
|
||||
[]reflect.Value{v(uintptr(2)), v(uintptr(1)), v(uintptr(3))},
|
||||
[]reflect.Value{v(uintptr(1)), v(uintptr(2)), v(uintptr(3))},
|
||||
},
|
||||
// SortableStructs.
|
||||
{
|
||||
// Note: not sorted - DisableMethods is set.
|
||||
[]reflect.Value{v(sortableStruct{2}), v(sortableStruct{1}), v(sortableStruct{3})},
|
||||
[]reflect.Value{v(sortableStruct{2}), v(sortableStruct{1}), v(sortableStruct{3})},
|
||||
},
|
||||
// UnsortableStructs.
|
||||
{
|
||||
// Note: not sorted - SpewKeys is false.
|
||||
[]reflect.Value{v(unsortableStruct{2}), v(unsortableStruct{1}), v(unsortableStruct{3})},
|
||||
[]reflect.Value{v(unsortableStruct{2}), v(unsortableStruct{1}), v(unsortableStruct{3})},
|
||||
},
|
||||
// Invalid.
|
||||
{
|
||||
[]reflect.Value{embedB, embedA, embedC},
|
||||
[]reflect.Value{embedB, embedA, embedC},
|
||||
},
|
||||
}
|
||||
for _, test := range tests {
|
||||
spew.SortValues(test.input)
|
||||
// reflect.DeepEqual cannot really make sense of reflect.Value,
|
||||
// probably because of all the pointer tricks. For instance,
|
||||
// v(2.0) != v(2.0) on a 32-bits system. Turn them into interface{}
|
||||
// instead.
|
||||
input := getInterfaces(test.input)
|
||||
expected := getInterfaces(test.expected)
|
||||
if !reflect.DeepEqual(input, expected) {
|
||||
t.Errorf("Sort mismatch:\n %v != %v", input, expected)
|
||||
}
|
||||
}
|
||||
cs := spew.ConfigState{DisableMethods: true, SpewKeys: false}
|
||||
helpTestSortValues(tests, &cs, t)
|
||||
}
|
||||
|
||||
// TestSortValuesWithMethods ensures the sort functionality for relect.Value
|
||||
// based sorting works as intended when using string methods.
|
||||
func TestSortValuesWithMethods(t *testing.T) {
|
||||
v := reflect.ValueOf
|
||||
|
||||
a := v("a")
|
||||
b := v("b")
|
||||
c := v("c")
|
||||
tests := []sortTestCase{
|
||||
// Ints.
|
||||
{
|
||||
[]reflect.Value{v(2), v(1), v(3)},
|
||||
[]reflect.Value{v(1), v(2), v(3)},
|
||||
},
|
||||
// Strings.
|
||||
{
|
||||
[]reflect.Value{b, a, c},
|
||||
[]reflect.Value{a, b, c},
|
||||
},
|
||||
// SortableStructs.
|
||||
{
|
||||
[]reflect.Value{v(sortableStruct{2}), v(sortableStruct{1}), v(sortableStruct{3})},
|
||||
[]reflect.Value{v(sortableStruct{1}), v(sortableStruct{2}), v(sortableStruct{3})},
|
||||
},
|
||||
// UnsortableStructs.
|
||||
{
|
||||
// Note: not sorted - SpewKeys is false.
|
||||
[]reflect.Value{v(unsortableStruct{2}), v(unsortableStruct{1}), v(unsortableStruct{3})},
|
||||
[]reflect.Value{v(unsortableStruct{2}), v(unsortableStruct{1}), v(unsortableStruct{3})},
|
||||
},
|
||||
}
|
||||
cs := spew.ConfigState{DisableMethods: false, SpewKeys: false}
|
||||
helpTestSortValues(tests, &cs, t)
|
||||
}
|
||||
|
||||
// TestSortValuesWithSpew ensures the sort functionality for relect.Value
|
||||
// based sorting works as intended when using spew to stringify keys.
|
||||
func TestSortValuesWithSpew(t *testing.T) {
|
||||
v := reflect.ValueOf
|
||||
|
||||
a := v("a")
|
||||
b := v("b")
|
||||
c := v("c")
|
||||
tests := []sortTestCase{
|
||||
// Ints.
|
||||
{
|
||||
[]reflect.Value{v(2), v(1), v(3)},
|
||||
[]reflect.Value{v(1), v(2), v(3)},
|
||||
},
|
||||
// Strings.
|
||||
{
|
||||
[]reflect.Value{b, a, c},
|
||||
[]reflect.Value{a, b, c},
|
||||
},
|
||||
// SortableStructs.
|
||||
{
|
||||
[]reflect.Value{v(sortableStruct{2}), v(sortableStruct{1}), v(sortableStruct{3})},
|
||||
[]reflect.Value{v(sortableStruct{1}), v(sortableStruct{2}), v(sortableStruct{3})},
|
||||
},
|
||||
// UnsortableStructs.
|
||||
{
|
||||
[]reflect.Value{v(unsortableStruct{2}), v(unsortableStruct{1}), v(unsortableStruct{3})},
|
||||
[]reflect.Value{v(unsortableStruct{1}), v(unsortableStruct{2}), v(unsortableStruct{3})},
|
||||
},
|
||||
}
|
||||
cs := spew.ConfigState{DisableMethods: true, SpewKeys: true}
|
||||
helpTestSortValues(tests, &cs, t)
|
||||
}
|
||||
|
12
Godeps/_workspace/src/github.com/davecgh/go-spew/spew/config.go
generated
vendored
12
Godeps/_workspace/src/github.com/davecgh/go-spew/spew/config.go
generated
vendored
@ -76,10 +76,16 @@ type ConfigState struct {
|
||||
|
||||
// SortKeys specifies map keys should be sorted before being printed. Use
|
||||
// this to have a more deterministic, diffable output. Note that only
|
||||
// native types (bool, int, uint, floats, uintptr and string) are supported
|
||||
// with other types sorted according to the reflect.Value.String() output
|
||||
// which guarantees display stability.
|
||||
// native types (bool, int, uint, floats, uintptr and string) and types
|
||||
// that support the error or Stringer interfaces (if methods are
|
||||
// enabled) are supported, with other types sorted according to the
|
||||
// reflect.Value.String() output which guarantees display stability.
|
||||
SortKeys bool
|
||||
|
||||
// SpewKeys specifies that, as a last resort attempt, map keys should
|
||||
// be spewed to strings and sorted by those strings. This is only
|
||||
// considered if SortKeys is true.
|
||||
SpewKeys bool
|
||||
}
|
||||
|
||||
// Config is the active configuration of the top-level functions.
|
||||
|
12
Godeps/_workspace/src/github.com/davecgh/go-spew/spew/doc.go
generated
vendored
12
Godeps/_workspace/src/github.com/davecgh/go-spew/spew/doc.go
generated
vendored
@ -99,9 +99,15 @@ The following configuration options are available:
|
||||
Specifies map keys should be sorted before being printed. Use
|
||||
this to have a more deterministic, diffable output. Note that
|
||||
only native types (bool, int, uint, floats, uintptr and string)
|
||||
are supported with other types sorted according to the
|
||||
reflect.Value.String() output which guarantees display stability.
|
||||
Natural map order is used by default.
|
||||
and types which implement error or Stringer interfaces are
|
||||
supported with other types sorted according to the
|
||||
reflect.Value.String() output which guarantees display
|
||||
stability. Natural map order is used by default.
|
||||
|
||||
* SpewKeys
|
||||
Specifies that, as a last resort attempt, map keys should be
|
||||
spewed to strings and sorted by those strings. This is only
|
||||
considered if SortKeys is true.
|
||||
|
||||
Dump Usage
|
||||
|
||||
|
2
Godeps/_workspace/src/github.com/davecgh/go-spew/spew/dump.go
generated
vendored
2
Godeps/_workspace/src/github.com/davecgh/go-spew/spew/dump.go
generated
vendored
@ -382,7 +382,7 @@ func (d *dumpState) dump(v reflect.Value) {
|
||||
numEntries := v.Len()
|
||||
keys := v.MapKeys()
|
||||
if d.cs.SortKeys {
|
||||
sortValues(keys)
|
||||
sortValues(keys, d.cs)
|
||||
}
|
||||
for i, key := range keys {
|
||||
d.dump(d.unpackValue(key))
|
||||
|
37
Godeps/_workspace/src/github.com/davecgh/go-spew/spew/dump_test.go
generated
vendored
37
Godeps/_workspace/src/github.com/davecgh/go-spew/spew/dump_test.go
generated
vendored
@ -64,9 +64,10 @@ package spew_test
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"github.com/davecgh/go-spew/spew"
|
||||
"testing"
|
||||
"unsafe"
|
||||
|
||||
"github.com/davecgh/go-spew/spew"
|
||||
)
|
||||
|
||||
// dumpTest is used to describe a test to be perfomed against the Dump method.
|
||||
@ -983,4 +984,38 @@ func TestDumpSortedKeys(t *testing.T) {
|
||||
if s != expected {
|
||||
t.Errorf("Sorted keys mismatch:\n %v %v", s, expected)
|
||||
}
|
||||
|
||||
s = cfg.Sdump(map[stringer]int{"1": 1, "3": 3, "2": 2})
|
||||
expected = `(map[spew_test.stringer]int) (len=3) {
|
||||
(spew_test.stringer) (len=1) stringer 1: (int) 1,
|
||||
(spew_test.stringer) (len=1) stringer 2: (int) 2,
|
||||
(spew_test.stringer) (len=1) stringer 3: (int) 3
|
||||
}
|
||||
`
|
||||
if s != expected {
|
||||
t.Errorf("Sorted keys mismatch:\n %v %v", s, expected)
|
||||
}
|
||||
|
||||
s = cfg.Sdump(map[pstringer]int{pstringer("1"): 1, pstringer("3"): 3, pstringer("2"): 2})
|
||||
expected = `(map[spew_test.pstringer]int) (len=3) {
|
||||
(spew_test.pstringer) (len=1) stringer 1: (int) 1,
|
||||
(spew_test.pstringer) (len=1) stringer 2: (int) 2,
|
||||
(spew_test.pstringer) (len=1) stringer 3: (int) 3
|
||||
}
|
||||
`
|
||||
if s != expected {
|
||||
t.Errorf("Sorted keys mismatch:\n %v %v", s, expected)
|
||||
}
|
||||
|
||||
s = cfg.Sdump(map[customError]int{customError(1): 1, customError(3): 3, customError(2): 2})
|
||||
expected = `(map[spew_test.customError]int) (len=3) {
|
||||
(spew_test.customError) error: 1: (int) 1,
|
||||
(spew_test.customError) error: 2: (int) 2,
|
||||
(spew_test.customError) error: 3: (int) 3
|
||||
}
|
||||
`
|
||||
if s != expected {
|
||||
t.Errorf("Sorted keys mismatch:\n %v %v", s, expected)
|
||||
}
|
||||
|
||||
}
|
||||
|
2
Godeps/_workspace/src/github.com/davecgh/go-spew/spew/format.go
generated
vendored
2
Godeps/_workspace/src/github.com/davecgh/go-spew/spew/format.go
generated
vendored
@ -309,7 +309,7 @@ func (f *formatState) format(v reflect.Value) {
|
||||
} else {
|
||||
keys := v.MapKeys()
|
||||
if f.cs.SortKeys {
|
||||
sortValues(keys)
|
||||
sortValues(keys, f.cs)
|
||||
}
|
||||
for i, key := range keys {
|
||||
if i > 0 {
|
||||
|
49
Godeps/_workspace/src/github.com/davecgh/go-spew/spew/format_test.go
generated
vendored
49
Godeps/_workspace/src/github.com/davecgh/go-spew/spew/format_test.go
generated
vendored
@ -69,9 +69,10 @@ package spew_test
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"github.com/davecgh/go-spew/spew"
|
||||
"testing"
|
||||
"unsafe"
|
||||
|
||||
"github.com/davecgh/go-spew/spew"
|
||||
)
|
||||
|
||||
// formatterTest is used to describe a test to be perfomed against NewFormatter.
|
||||
@ -1478,6 +1479,22 @@ func TestFormatter(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
type testStruct struct {
|
||||
x int
|
||||
}
|
||||
|
||||
func (ts testStruct) String() string {
|
||||
return fmt.Sprintf("ts.%d", ts.x)
|
||||
}
|
||||
|
||||
type testStructP struct {
|
||||
x int
|
||||
}
|
||||
|
||||
func (ts *testStructP) String() string {
|
||||
return fmt.Sprintf("ts.%d", ts.x)
|
||||
}
|
||||
|
||||
func TestPrintSortedKeys(t *testing.T) {
|
||||
cfg := spew.ConfigState{SortKeys: true}
|
||||
s := cfg.Sprint(map[int]string{1: "1", 3: "3", 2: "2"})
|
||||
@ -1485,4 +1502,34 @@ func TestPrintSortedKeys(t *testing.T) {
|
||||
if s != expected {
|
||||
t.Errorf("Sorted keys mismatch:\n %v %v", s, expected)
|
||||
}
|
||||
|
||||
s = cfg.Sprint(map[stringer]int{"1": 1, "3": 3, "2": 2})
|
||||
expected = "map[stringer 1:1 stringer 2:2 stringer 3:3]"
|
||||
if s != expected {
|
||||
t.Errorf("Sorted keys mismatch:\n %v %v", s, expected)
|
||||
}
|
||||
|
||||
s = cfg.Sprint(map[pstringer]int{pstringer("1"): 1, pstringer("3"): 3, pstringer("2"): 2})
|
||||
expected = "map[stringer 1:1 stringer 2:2 stringer 3:3]"
|
||||
if s != expected {
|
||||
t.Errorf("Sorted keys mismatch:\n %v %v", s, expected)
|
||||
}
|
||||
|
||||
s = cfg.Sprint(map[testStruct]int{testStruct{1}: 1, testStruct{3}: 3, testStruct{2}: 2})
|
||||
expected = "map[ts.1:1 ts.2:2 ts.3:3]"
|
||||
if s != expected {
|
||||
t.Errorf("Sorted keys mismatch:\n %v %v", s, expected)
|
||||
}
|
||||
|
||||
s = cfg.Sprint(map[testStructP]int{testStructP{1}: 1, testStructP{3}: 3, testStructP{2}: 2})
|
||||
expected = "map[ts.1:1 ts.2:2 ts.3:3]"
|
||||
if s != expected {
|
||||
t.Errorf("Sorted keys mismatch:\n %v %v", s, expected)
|
||||
}
|
||||
|
||||
s = cfg.Sprint(map[customError]int{customError(1): 1, customError(3): 3, customError(2): 2})
|
||||
expected = "map[error: 1:1 error: 2:2 error: 3:3]"
|
||||
if s != expected {
|
||||
t.Errorf("Sorted keys mismatch:\n %v %v", s, expected)
|
||||
}
|
||||
}
|
||||
|
4
Godeps/_workspace/src/github.com/davecgh/go-spew/spew/internal_test.go
generated
vendored
4
Godeps/_workspace/src/github.com/davecgh/go-spew/spew/internal_test.go
generated
vendored
@ -151,6 +151,6 @@ func TestAddedReflectValue(t *testing.T) {
|
||||
|
||||
// SortValues makes the internal sortValues function available to the test
|
||||
// package.
|
||||
func SortValues(values []reflect.Value) {
|
||||
sortValues(values)
|
||||
func SortValues(values []reflect.Value, cs *ConfigState) {
|
||||
sortValues(values, cs)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user