MCPcopy
hub / github.com/google/mangle / TestEqualsStructured

Function TestEqualsStructured

ast/ast_test.go:113–155  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

111}
112
113func TestEqualsStructured(t *testing.T) {
114 tests := []struct {
115 left *Constant
116 right *Constant
117 want bool
118 }{
119 {&fooPair, &fooList, false},
120 {&fooFooPair, &fooFooList, false},
121 {&fooPair, &fooName, false},
122 {&fooBarPair, fooBarMap, false},
123 {fooBarStruct, fooBarMap, false},
124 {&fooBarList, fooBarStruct, false},
125 {&fooBarPair, &fooBarPair, true},
126 {&fooBarPair, &barFooPair, false},
127 {&fooBarList, &barFooList, false},
128 {&fooBarList, &fooBarList, true},
129 {mapExample, mapExampleSame, true},
130 {mapExample, mapExampleOther, false},
131 {mapExample, &MapNil, false},
132 {&MapNil, mapExample, false},
133 {&MapNil, &MapNil, true},
134 {structExample, structExampleSame, true},
135 {structExample, structExampleOther, false},
136 {structExample, &StructNil, false},
137 {&StructNil, structExample, false},
138 }
139 for _, testcase := range tests {
140 got := testcase.left.Equals(testcase.right)
141 if got != testcase.want {
142 t.Errorf("(%v).Equals(%v) got %v want %v", testcase.left, testcase.right, got, testcase.want)
143 }
144 lh, rh := testcase.left.Hash(), testcase.right.Hash()
145 if testcase.want {
146 if lh != rh {
147 t.Errorf("(%v).Hash() %d != (%v).Hash() %d but want same", testcase.left, lh, testcase.right, rh)
148 }
149 } else {
150 if lh == rh {
151 t.Errorf("(%v).Hash() %d == (%v).Hash() %d but want different", testcase.left, lh, testcase.right, rh)
152 }
153 }
154 }
155}
156
157func TestEqualsSlice(t *testing.T) {
158 tests := []struct {

Callers

nothing calls this directly

Calls 2

EqualsMethod · 0.65
HashMethod · 0.65

Tested by

no test coverage detected