MCPcopy Create free account
hub / github.com/stretchr/testify / ExampleValueAssertionFunc

Function ExampleValueAssertionFunc

assert/assertions_test.go:2787–2813  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2785}
2786
2787func ExampleValueAssertionFunc() {
2788 t := &testing.T{} // provided by test
2789
2790 dumbParse := func(input string) interface{} {
2791 var x interface{}
2792 _ = json.Unmarshal([]byte(input), &x)
2793 return x
2794 }
2795
2796 tests := []struct {
2797 name string
2798 arg string
2799 assertion ValueAssertionFunc
2800 }{
2801 {"true is not nil", "true", NotNil},
2802 {"empty string is nil", "", Nil},
2803 {"zero is not nil", "0", NotNil},
2804 {"zero is zero", "0", Zero},
2805 {"false is zero", "false", Zero},
2806 }
2807
2808 for _, tt := range tests {
2809 t.Run(tt.name, func(t *testing.T) {
2810 tt.assertion(t, dumbParse(tt.arg))
2811 })
2812 }
2813}
2814
2815func TestValueAssertionFunc(t *testing.T) {
2816 tests := []struct {

Callers

nothing calls this directly

Calls 1

RunMethod · 0.65

Tested by

no test coverage detected