Compares two trees, disregarding the contents of the leaves.
(a, b *TreeNode)
| 174 | |
| 175 | // Compares two trees, disregarding the contents of the leaves. |
| 176 | func 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. |
| 206 | const wantTreeJSON = ` |