|
1 | 1 | package errors |
2 | 2 |
|
3 | 3 | import ( |
4 | | - "bytes" |
5 | 4 | "errors" |
6 | 5 | "fmt" |
7 | 6 | "io" |
@@ -95,57 +94,6 @@ func TestCause(t *testing.T) { |
95 | 94 | } |
96 | 95 | } |
97 | 96 |
|
98 | | -func TestFprintError(t *testing.T) { |
99 | | - x := New("error") |
100 | | - tests := []struct { |
101 | | - err error |
102 | | - want string |
103 | | - }{{ |
104 | | - // nil error is nil |
105 | | - err: nil, |
106 | | - }, { |
107 | | - // explicit nil error is nil |
108 | | - err: (error)(nil), |
109 | | - }, { |
110 | | - // uncaused error is unaffected |
111 | | - err: io.EOF, |
112 | | - want: "EOF\n", |
113 | | - }, { |
114 | | - err: Wrap(io.EOF, "cause error"), |
115 | | - want: "EOF\n" + |
116 | | - "github.com/pkg/errors/errors_test.go:114: cause error\n", |
117 | | - }, { |
118 | | - err: x, // return from errors.New |
119 | | - want: "github.com/pkg/errors/errors_test.go:99: error\n", |
120 | | - }, { |
121 | | - err: Wrap(x, "message"), |
122 | | - want: "github.com/pkg/errors/errors_test.go:99: error\n" + |
123 | | - "github.com/pkg/errors/errors_test.go:121: message\n", |
124 | | - }, { |
125 | | - err: Wrap(io.EOF, "message"), |
126 | | - want: "EOF\n" + |
127 | | - "github.com/pkg/errors/errors_test.go:125: message\n", |
128 | | - }, { |
129 | | - err: Wrap(Wrap(x, "message"), "another message"), |
130 | | - want: "github.com/pkg/errors/errors_test.go:99: error\n" + |
131 | | - "github.com/pkg/errors/errors_test.go:129: message\n" + |
132 | | - "github.com/pkg/errors/errors_test.go:129: another message\n", |
133 | | - }, { |
134 | | - err: Wrapf(x, "message"), |
135 | | - want: "github.com/pkg/errors/errors_test.go:99: error\n" + |
136 | | - "github.com/pkg/errors/errors_test.go:134: message\n", |
137 | | - }} |
138 | | - |
139 | | - for i, tt := range tests { |
140 | | - var w bytes.Buffer |
141 | | - Fprint(&w, tt.err) |
142 | | - got := w.String() |
143 | | - if got != tt.want { |
144 | | - t.Errorf("test %d: Fprint(w, %q): got %q, want %q", i+1, tt.err, got, tt.want) |
145 | | - } |
146 | | - } |
147 | | -} |
148 | | - |
149 | 97 | func TestWrapfNil(t *testing.T) { |
150 | 98 | got := Wrapf(nil, "no error") |
151 | 99 | if got != nil { |
|
0 commit comments