MCPcopy Create free account
hub / github.com/expr-lang/expr / ExampleErrorAssertionFunc

Function ExampleErrorAssertionFunc

internal/testify/require/requirements_test.go:537–561  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

535}
536
537func ExampleErrorAssertionFunc() {
538 t := &testing.T{} // provided by test
539
540 dumbParseNum := func(input string, v interface{}) error {
541 return json.Unmarshal([]byte(input), v)
542 }
543
544 tests := []struct {
545 name string
546 arg string
547 assertion ErrorAssertionFunc
548 }{
549 {"1.2 is number", "1.2", NoError},
550 {"1.2.3 not number", "1.2.3", Error},
551 {"true is not number", "true", Error},
552 {"3 is number", "3", NoError},
553 }
554
555 for _, tt := range tests {
556 t.Run(tt.name, func(t *testing.T) {
557 var x float64
558 tt.assertion(t, dumbParseNum(tt.arg, &x))
559 })
560 }
561}
562
563func TestErrorAssertionFunc(t *testing.T) {
564 tests := []struct {

Callers

nothing calls this directly

Calls 1

RunMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…