MCPcopy Index your code
hub / github.com/labstack/echo / TestValueBinder_Float32s

Function TestValueBinder_Float32s

binder_test.go:1685–1779  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1683}
1684
1685func TestValueBinder_Float32s(t *testing.T) {
1686 var testCases = []struct {
1687 name string
1688 whenURL string
1689 expectError string
1690 givenBindErrors []error
1691 expectValue []float32
1692 givenFailFast bool
1693 whenMust bool
1694 }{
1695 {
1696 name: "ok, binds value",
1697 whenURL: "/search?param=4.3&param=0",
1698 expectValue: []float32{4.3, 0},
1699 },
1700 {
1701 name: "ok, params values empty, value is not changed",
1702 whenURL: "/search?nope=1",
1703 expectValue: []float32(nil),
1704 },
1705 {
1706 name: "nok, previous errors fail fast without binding value",
1707 givenFailFast: true,
1708 givenBindErrors: []error{errors.New("previous error")},
1709 whenURL: "/search?param=1&param=100",
1710 expectValue: []float32(nil),
1711 expectError: "previous error",
1712 },
1713 {
1714 name: "nok, conversion fails, value is not changed",
1715 whenURL: "/search?param=nope&param=100",
1716 expectValue: []float32(nil),
1717 expectError: "code=400, message=failed to bind field value to float32, err=strconv.ParseFloat: parsing \"nope\": invalid syntax, field=param",
1718 },
1719 {
1720 name: "nok, conversion fails fast, value is not changed",
1721 givenFailFast: true,
1722 whenURL: "/search?param=0&param=nope&param=100",
1723 expectValue: []float32(nil),
1724 expectError: "code=400, message=failed to bind field value to float32, err=strconv.ParseFloat: parsing \"nope\": invalid syntax, field=param",
1725 },
1726 {
1727 name: "ok (must), binds value",
1728 whenMust: true,
1729 whenURL: "/search?param=4.3&param=0",
1730 expectValue: []float32{4.3, 0},
1731 },
1732 {
1733 name: "ok (must), params values empty, returns error, value is not changed",
1734 whenMust: true,
1735 whenURL: "/search?nope=1",
1736 expectValue: []float32(nil),
1737 expectError: "code=400, message=required field value is empty, field=param",
1738 },
1739 {
1740 name: "nok (must), previous errors fail fast without binding value",
1741 givenFailFast: true,
1742 givenBindErrors: []error{errors.New("previous error")},

Callers

nothing calls this directly

Calls 6

createTestContextFunction · 0.85
QueryParamsBinderFunction · 0.85
FailFastMethod · 0.80
BindErrorMethod · 0.80
MustFloat32sMethod · 0.80
Float32sMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…