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

Function TestValueBinder_Float32

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

Source from the content-addressed store, hash-verified

1594}
1595
1596func TestValueBinder_Float32(t *testing.T) {
1597 var testCases = []struct {
1598 name string
1599 whenURL string
1600 expectError string
1601 givenBindErrors []error
1602 expectValue float32
1603 givenNoFailFast bool
1604 whenMust bool
1605 }{
1606 {
1607 name: "ok, binds value",
1608 whenURL: "/search?param=4.3&param=1",
1609 expectValue: 4.3,
1610 },
1611 {
1612 name: "ok, params values empty, value is not changed",
1613 whenURL: "/search?nope=1",
1614 expectValue: 1.123,
1615 },
1616 {
1617 name: "nok, previous errors fail fast without binding value",
1618 givenNoFailFast: true,
1619 whenURL: "/search?param=1&param=100",
1620 expectValue: 1.123,
1621 expectError: "previous error",
1622 },
1623 {
1624 name: "nok, conversion fails, value is not changed",
1625 whenURL: "/search?param=nope&param=100",
1626 expectValue: 1.123,
1627 expectError: "code=400, message=failed to bind field value to float32, err=strconv.ParseFloat: parsing \"nope\": invalid syntax, field=param",
1628 },
1629 {
1630 name: "ok (must), binds value",
1631 whenMust: true,
1632 whenURL: "/search?param=4.3&param=100",
1633 expectValue: 4.3,
1634 },
1635 {
1636 name: "ok (must), params values empty, returns error, value is not changed",
1637 whenMust: true,
1638 whenURL: "/search?nope=1",
1639 expectValue: 1.123,
1640 expectError: "code=400, message=required field value is empty, field=param",
1641 },
1642 {
1643 name: "nok (must), previous errors fail fast without binding value",
1644 givenNoFailFast: true,
1645 whenMust: true,
1646 whenURL: "/search?param=1&param=100",
1647 expectValue: 1.123,
1648 expectError: "previous error",
1649 },
1650 {
1651 name: "nok (must), conversion fails, value is not changed",
1652 whenMust: true,
1653 whenURL: "/search?param=nope&param=100",

Callers

nothing calls this directly

Calls 6

createTestContextFunction · 0.85
QueryParamsBinderFunction · 0.85
FailFastMethod · 0.80
BindErrorMethod · 0.80
MustFloat32Method · 0.80
Float32Method · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…