MCPcopy
hub / github.com/TheAlgorithms/Go / TestLCA

Function TestLCA

graph/lowestcommonancestor_test.go:15–147  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

13}
14
15func TestLCA(t *testing.T) {
16 testSuites := []struct {
17 numbersVertex int
18 root int
19 edges []TreeEdge
20 queries []Query
21 }{
22 {
23 numbersVertex: 2,
24 root: 0,
25 edges: []TreeEdge{
26 {
27 from: 0,
28 to: 1,
29 },
30 },
31 queries: []Query{
32 {
33 u: 0,
34 v: 0,
35 expected: 0,
36 },
37 {
38 u: 0,
39 v: 1,
40 expected: 0,
41 },
42 {
43 u: 1,
44 v: 1,
45 expected: 1,
46 },
47 },
48 }, {
49 numbersVertex: 1,
50 root: 0,
51 edges: []TreeEdge{},
52 queries: []Query{
53 {
54 u: 0,
55 v: 0,
56 expected: 0,
57 },
58 },
59 }, {
60 numbersVertex: 9,
61 root: 7,
62 edges: []TreeEdge{
63 {
64 from: 0,
65 to: 1,
66 },
67 {
68 from: 0,
69 to: 2,
70 },
71 {
72 from: 2,

Callers

nothing calls this directly

Calls 3

GetLCAMethod · 0.95
NewTreeFunction · 0.85
LowestCommonAncestorFunction · 0.85

Tested by

no test coverage detected