Repository: labstack/echo
File: bind_test.go (Go)

Code before:
	if assert.NoError(t, setBoolField("true", val.FieldByName("B"))) {
		assert.Equal(t, true, ts.B)
	}
	if assert.NoError(t, setBoolField("", val.FieldByName("B"))) {
		assert.Equal(t, false, ts.B)
	}

	ok, err := unmarshalFieldNonPtr("2016-12-06T19:09:05Z", val.FieldByName("T"))
	if assert.NoError(t, err) {
		assert.Equal(t, ok, true)
		assert.Equal(t, Timestamp(time.Date(2016, 12, 6, 19, 9, 5, 0, time.UTC)), ts.T)
	}
}

func BenchmarkBindbindDataWithTags(b *testing.B) {
	b.ReportAllocs()
	assertion := assert.New(b)
	ts := new(bindTestStructWithTags)
	binder := new(DefaultBinder)
	var err error
	b.ResetTimer()
	for i := 0; i < b.N; i++ {
		err = binder.bindData(ts, values, "form")
	}
	assertion.NoError(err)
	assertBindTestStruct(assertion, (*bindTestStruct)(ts))
}

func assertBindTestStruct(a *assert.Assertions, ts *bindTestStruct) {
	a.Equal(0, ts.I)
	a.Equal(int8(8), ts.I8)
	a.Equal(int16(16), ts.I16)
	a.Equal(int32(32), ts.I32)
	a.Equal(int64(64), ts.I64)
	a.Equal(uint(0), ts.UI)
	a.Equal(uint8(8), ts.UI8)
	a.Equal(uint16(16), ts.UI16)
	a.Equal(uint32(32), ts.UI32)
	a.Equal(uint64(64), ts.UI64)
	a.Equal(true, ts.B)
	a.Equal(float32(32.5), ts.F32)
	a.Equal(float64(64.5), ts.F64)
	a.Equal("test", ts.S)
	a.Equal("", ts.GetCantSet())
}

func testBindOkay(t *testing.T, r io.Reader, query url.Values, ctype string) {
	e := New()
	path := "/"
	if len(query) > 0 {
		path += "?" + query.Encode()

Review comment (suggestion):
You could change `assertBindTestStruct` to take in `testing.TB` interface. In that way you can pass in  `*testing.T` and `*testing.B` 

```go
func assertBindTestStruct(t testing.TB, ts *bindTestStruct) {
	assert.Equal(t, 0, ts.I)
	assert.Equal(t, int8(8), ts.I8)
	assert.Equal(t, int16(16), ts.I16)
	assert.Equal(t, int32(32), ts.I32)
	assert.Equal(t, int64(64), ts.I64)
	assert.Equal(t, uint(0), ts.UI)
	assert.Equal(t, uint8(8), ts.UI8)
	assert.Equal(t, uint16(16), ts.UI16)
	assert.Equal(t, uint32(32), ts.UI32)
	assert.Equal(t, uint64(64), ts.UI64)
	assert.Equal(t, true, ts.B)
	assert.Equal(t, float32(32.5), ts.F32)
	assert.Equal(t, float64(64.5), ts.F64)
	assert.Equal(t, "test", ts.S)
	assert.Equal(t, "", ts.GetCantSet())
}
```

Code after:
		assert.Equal(t, true, ts.B)
	}
	if assert.NoError(t, setBoolField("", val.FieldByName("B"))) {
		assert.Equal(t, false, ts.B)
	}

	ok, err := unmarshalFieldNonPtr("2016-12-06T19:09:05Z", val.FieldByName("T"))
	if assert.NoError(t, err) {
		assert.Equal(t, ok, true)
		assert.Equal(t, Timestamp(time.Date(2016, 12, 6, 19, 9, 5, 0, time.UTC)), ts.T)
	}
}

func BenchmarkBindbindDataWithTags(b *testing.B) {
	b.ReportAllocs()
	ts := new(bindTestStructWithTags)
	binder := new(DefaultBinder)
	var err error
	b.ResetTimer()
	for i := 0; i < b.N; i++ {
		err = binder.bindData(ts, values, "form")
	}
	assert.NoError(b, err)
	assertBindTestStruct(b, (*bindTestStruct)(ts))
}

func assertBindTestStruct(tb testing.TB, ts *bindTestStruct) {
	assert.Equal(tb, 0, ts.I)
	assert.Equal(tb, int8(8), ts.I8)
	assert.Equal(tb, int16(16), ts.I16)
	assert.Equal(tb, int32(32), ts.I32)
	assert.Equal(tb, int64(64), ts.I64)
	assert.Equal(tb, uint(0), ts.UI)
	assert.Equal(tb, uint8(8), ts.UI8)
	assert.Equal(tb, uint16(16), ts.UI16)
	assert.Equal(tb, uint32(32), ts.UI32)
	assert.Equal(tb, uint64(64), ts.UI64)
	assert.Equal(tb, true, ts.B)
	assert.Equal(tb, float32(32.5), ts.F32)
	assert.Equal(tb, float64(64.5), ts.F64)
	assert.Equal(tb, "test", ts.S)
	assert.Equal(tb, "", ts.GetCantSet())
}

func testBindOkay(t *testing.T, r io.Reader, query url.Values, ctype string) {
	e := New()
	path := "/"
	if len(query) > 0 {
		path += "?" + query.Encode()
	}
	req := httptest.NewRequest(http.MethodPost, path, r)