We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
`import ( "fmt" "testing"
"github.com/go-test/deep" . "github.com/smartystreets/goconvey/convey"
)
func TestStructCompare(t *testing.T) {
type BB struct { i_BB int I_BB int S_BB string M_BB map[string]string A_BB []int } type AA struct { i_AA int I_AA int S_AA string M_AA map[string]string A_AA []int P_AA *BB B_AA BB } Convey("test struct compare", t, func() { a1 := AA{} a2 := AA{} a1.I_AA = 1 a1.S_AA = "cc" a1.M_AA = map[string]string{"1": "2"} a1.A_AA = []int{3, 4} a1.P_AA = &BB{I_BB: 21, M_BB: map[string]string{"15": "6"}} a1.B_AA = BB{I_BB: 21, M_BB: map[string]string{"15": "6"}, A_BB: []int{1, 2}} a2.I_AA = 2 a2.S_AA = "dd" a2.M_AA = map[string]string{"5": "6"} a2.A_AA = []int{7, 8} a2.P_AA = &BB{I_BB: 21, M_BB: map[string]string{"25": "6"}} a2.B_AA = BB{I_BB: 21, M_BB: map[string]string{"25": "6"}, A_BB: []int{3, 4}} fmt.Println() fmt.Printf("%+v \n", a1) fmt.Printf("%+v \n", a2) if diff := deep.Equal(a1, a2); diff != nil { for i, s := range diff { fmt.Println(i, s) } t.Error(diff) } })
}` output:
{i_AA:0 I_AA:1 S_AA:cc M_AA:map[1:2] A_AA:[3 4] P_AA:0x140009aaf00 B_AA:{i_BB:0 I_BB:21 S_BB: M_BB:map[15:6] A_BB:[1 2]}} {i_AA:0 I_AA:2 S_AA:dd M_AA:map[5:6] A_AA:[7 8] P_AA:0x140009aaf40 B_AA:{i_BB:0 I_BB:21 S_BB: M_BB:map[25:6] A_BB:[3 4]}} 0 I_AA: 1 != 2 1 S_AA: cc != dd 2 M_AA.map[1]: 2 != 3 M_AA.map[5]: != 6 4 A_AA.slice[0]: 3 != 7 5 A_AA.slice[1]: 4 != 8 6 P_AA.M_BB.map[15]: 6 != 7 P_AA.M_BB.map[25]: != 6 8 B_AA.M_BB.map[15]: 6 != 9 B_AA.M_BB.map[25]: != 6
BB.A_BB is diff,but no.
The text was updated successfully, but these errors were encountered:
No branches or pull requests
`import (
"fmt"
"testing"
)
func TestStructCompare(t *testing.T) {
}`
output:
{i_AA:0 I_AA:1 S_AA:cc M_AA:map[1:2] A_AA:[3 4] P_AA:0x140009aaf00 B_AA:{i_BB:0 I_BB:21 S_BB: M_BB:map[15:6] A_BB:[1 2]}}
{i_AA:0 I_AA:2 S_AA:dd M_AA:map[5:6] A_AA:[7 8] P_AA:0x140009aaf40 B_AA:{i_BB:0 I_BB:21 S_BB: M_BB:map[25:6] A_BB:[3 4]}}
0 I_AA: 1 != 2
1 S_AA: cc != dd
2 M_AA.map[1]: 2 !=
3 M_AA.map[5]: != 6
4 A_AA.slice[0]: 3 != 7
5 A_AA.slice[1]: 4 != 8
6 P_AA.M_BB.map[15]: 6 !=
7 P_AA.M_BB.map[25]: != 6
8 B_AA.M_BB.map[15]: 6 !=
9 B_AA.M_BB.map[25]: != 6
BB.A_BB is diff,but no.
The text was updated successfully, but these errors were encountered: