MCPcopy Index your code
hub / github.com/TheAlgorithms/Go / TestLCAWithLargeTree

Function TestLCAWithLargeTree

graph/lowestcommonancestor_test.go:233–250  ·  view source on GitHub ↗

Test with the tree with up to 2000 vertices.

(t *testing.T)

Source from the content-addressed store, hash-verified

231
232// Test with the tree with up to 2000 vertices.
233func TestLCAWithLargeTree(t *testing.T) {
234 const MAXTEST int = 20
235
236 for test := 1; test <= MAXTEST; test++ {
237 tree := generateTree()
238 LowestCommonAncestor(tree)
239
240 queries := generateQuery(tree)
241
242 for qi, query := range queries {
243 actual := tree.GetLCA(query.u, query.v)
244 expected := query.expected
245 if actual != expected {
246 t.Errorf("\nTest #%d:\nQuery #%d: u = %d, v = %d\nExpected %d, but actual %d", test, qi, query.u, query.v, expected, actual)
247 }
248 }
249 }
250}

Callers

nothing calls this directly

Calls 4

generateTreeFunction · 0.85
LowestCommonAncestorFunction · 0.85
generateQueryFunction · 0.85
GetLCAMethod · 0.65

Tested by

no test coverage detected