123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- package spew
- import (
- "bytes"
- "reflect"
- "testing"
- )
- type dummyFmtState struct {
- bytes.Buffer
- }
- func (dfs *dummyFmtState) Flag(f int) bool {
- if f == int('+') {
- return true
- }
- return false
- }
- func (dfs *dummyFmtState) Precision() (int, bool) {
- return 0, false
- }
- func (dfs *dummyFmtState) Width() (int, bool) {
- return 0, false
- }
- func TestInvalidReflectValue(t *testing.T) {
- i := 1
-
- v := new(reflect.Value)
- buf := new(bytes.Buffer)
- d := dumpState{w: buf, cs: &Config}
- d.dump(*v)
- s := buf.String()
- want := "<invalid>"
- if s != want {
- t.Errorf("InvalidReflectValue #%d\n got: %s want: %s", i, s, want)
- }
- i++
-
- buf2 := new(dummyFmtState)
- f := formatState{value: *v, cs: &Config, fs: buf2}
- f.format(*v)
- s = buf2.String()
- want = "<invalid>"
- if s != want {
- t.Errorf("InvalidReflectValue #%d got: %s want: %s", i, s, want)
- }
- }
- func SortValues(values []reflect.Value, cs *ConfigState) {
- sortValues(values, cs)
- }
|