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

Function Test_samePointers

assert/assertions_test.go:650–713  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

648}
649
650func Test_samePointers(t *testing.T) {
651 p := ptr(2)
652
653 type args struct {
654 first interface{}
655 second interface{}
656 }
657 tests := []struct {
658 name string
659 args args
660 same BoolAssertionFunc
661 ok BoolAssertionFunc
662 }{
663 {
664 name: "1 != 2",
665 args: args{first: 1, second: 2},
666 same: False,
667 ok: False,
668 },
669 {
670 name: "1 != 1 (not same ptr)",
671 args: args{first: 1, second: 1},
672 same: False,
673 ok: False,
674 },
675 {
676 name: "ptr(1) == ptr(1)",
677 args: args{first: p, second: p},
678 same: True,
679 ok: True,
680 },
681 {
682 name: "int(1) != float32(1)",
683 args: args{first: int(1), second: float32(1)},
684 same: False,
685 ok: False,
686 },
687 {
688 name: "array != slice",
689 args: args{first: [2]int{1, 2}, second: []int{1, 2}},
690 same: False,
691 ok: False,
692 },
693 {
694 name: "non-pointer vs pointer (1 != ptr(2))",
695 args: args{first: 1, second: p},
696 same: False,
697 ok: False,
698 },
699 {
700 name: "pointer vs non-pointer (ptr(2) != 1)",
701 args: args{first: p, second: 1},
702 same: False,
703 ok: False,
704 },
705 }
706 for _, tt := range tests {
707 t.Run(tt.name, func(t *testing.T) {

Callers

nothing calls this directly

Calls 3

ptrFunction · 0.85
samePointersFunction · 0.85
RunMethod · 0.65

Tested by

no test coverage detected