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

Function ExampleErrorAssertionFunc

internal/testify/assert/assertions_test.go:2674–2698  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2672}
2673
2674func ExampleErrorAssertionFunc() {
2675 t := &testing.T{} // provided by test
2676
2677 dumbParseNum := func(input string, v interface{}) error {
2678 return json.Unmarshal([]byte(input), v)
2679 }
2680
2681 tests := []struct {
2682 name string
2683 arg string
2684 assertion ErrorAssertionFunc
2685 }{
2686 {"1.2 is number", "1.2", NoError},
2687 {"1.2.3 not number", "1.2.3", Error},
2688 {"true is not number", "true", Error},
2689 {"3 is number", "3", NoError},
2690 }
2691
2692 for _, tt := range tests {
2693 t.Run(tt.name, func(t *testing.T) {
2694 var x float64
2695 tt.assertion(t, dumbParseNum(tt.arg, &x))
2696 })
2697 }
2698}
2699
2700func TestErrorAssertionFunc(t *testing.T) {
2701 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…