MCPcopy Create free account
hub / github.com/bobg/hashsplit / compareTrees

Function compareTrees

hashsplit_test.go:176–203  ·  view source on GitHub ↗

Compares two trees, disregarding the contents of the leaves.

(a, b *TreeNode)

Source from the content-addressed store, hash-verified

174
175// Compares two trees, disregarding the contents of the leaves.
176func compareTrees(a, b *TreeNode) bool {
177 if a == nil {
178 return b == nil
179 }
180 if b == nil {
181 return false
182 }
183 if len(a.Children) != len(b.Children) {
184 return false
185 }
186 if len(a.Chunks) != len(b.Chunks) {
187 return false
188 }
189 if a.Size != b.Size {
190 return false
191 }
192 if a.Offset != b.Offset {
193 return false
194 }
195
196 for i := 0; i < len(a.Children); i++ {
197 if !compareTrees(a.Children[i], b.Children[i]) {
198 return false
199 }
200 }
201
202 return true
203}
204
205// The shape, but not the leaf content, of the expected tree.
206const wantTreeJSON = `

Callers 2

TestTreeFunction · 0.85
TestSeekFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected