| 172 | } |
| 173 | |
| 174 | func report(tb testing.TB, got, want any, desc string, showWant bool, options ...Option) { |
| 175 | tb.Helper() |
| 176 | buffer := &bytes.Buffer{} |
| 177 | if len(options) > 0 { |
| 178 | buffer.WriteString(options[len(options)-1].message()) |
| 179 | } |
| 180 | buffer.WriteString("\n") |
| 181 | fmt.Fprintf(buffer, "assertion:\t%s\n", desc) |
| 182 | fmt.Fprintf(buffer, "got:\t%+v\n", got) |
| 183 | if showWant { |
| 184 | fmt.Fprintf(buffer, "want:\t%+v\n", want) |
| 185 | } |
| 186 | tb.Error(buffer.String()) |
| 187 | } |
| 188 | |
| 189 | func isNil(got any) bool { |
| 190 | // Simple case, true only when the user directly passes a literal nil. |