| 275 | } |
| 276 | |
| 277 | func TestContextReset(t *testing.T) { |
| 278 | router := New() |
| 279 | c := router.allocateContext(0) |
| 280 | assert.Equal(t, c.engine, router) |
| 281 | |
| 282 | c.index = 2 |
| 283 | c.Writer = &responseWriter{ResponseWriter: httptest.NewRecorder()} |
| 284 | c.Params = Params{Param{}} |
| 285 | c.Error(errors.New("test")) //nolint: errcheck |
| 286 | c.Set("foo", "bar") |
| 287 | c.reset() |
| 288 | |
| 289 | assert.False(t, c.IsAborted()) |
| 290 | assert.Nil(t, c.Keys) |
| 291 | assert.Nil(t, c.Accepted) |
| 292 | assert.Empty(t, c.Errors) |
| 293 | assert.Empty(t, c.Errors.Errors()) |
| 294 | assert.Empty(t, c.Errors.ByType(ErrorTypeAny)) |
| 295 | assert.Empty(t, c.Params) |
| 296 | assert.EqualValues(t, -1, c.index) |
| 297 | assert.Equal(t, c.Writer.(*responseWriter), &c.writermem) |
| 298 | } |
| 299 | |
| 300 | func TestContextHandlers(t *testing.T) { |
| 301 | c, _ := CreateTestContext(httptest.NewRecorder()) |