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

Function ExampleComparisonAssertionFunc

assert/assertions_test.go:2724–2752  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2722}
2723
2724func ExampleComparisonAssertionFunc() {
2725 t := &testing.T{} // provided by test
2726
2727 adder := func(x, y int) int {
2728 return x + y
2729 }
2730
2731 type args struct {
2732 x int
2733 y int
2734 }
2735
2736 tests := []struct {
2737 name string
2738 args args
2739 expect int
2740 assertion ComparisonAssertionFunc
2741 }{
2742 {"2+2=4", args{2, 2}, 4, Equal},
2743 {"2+2!=5", args{2, 2}, 5, NotEqual},
2744 {"2+3==5", args{2, 3}, 5, Exactly},
2745 }
2746
2747 for _, tt := range tests {
2748 t.Run(tt.name, func(t *testing.T) {
2749 tt.assertion(t, tt.expect, adder(tt.args.x, tt.args.y))
2750 })
2751 }
2752}
2753
2754func TestComparisonAssertionFunc(t *testing.T) {
2755 type iface interface {

Callers

nothing calls this directly

Calls 1

RunMethod · 0.65

Tested by

no test coverage detected