Skip to content

Commit 0fa3d00

Browse files
committed
Add compatibility tests for Subgraph children
1 parent 2e1fd63 commit 0fa3d00

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

Tests/OpenAttributeGraphCompatibilityTests/Graph/SubgraphCompatibilityTests.swift

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,59 @@ struct SubgraphCompatibilityTests {
7676
#expect(notifiedCount == 0)
7777
}
7878
}
79+
80+
@Suite(.disabled(if: !compatibilityTestEnabled, "Subgraph children is not implemented"), .graphScope)
81+
struct ChildrenTests {
82+
83+
@Test
84+
func addChild() {
85+
let graph = Graph()
86+
let subgraph = Subgraph(graph: graph)
87+
let child = Subgraph(graph: graph)
88+
89+
subgraph.addChild(child)
90+
#expect(subgraph.childCount == 1)
91+
#expect(subgraph.isAncestor(of: child) == true)
92+
93+
#expect(subgraph.child(at: 0, tag: nil) == child)
94+
95+
#expect(child.parentCount == 1)
96+
#expect(child.parent(at: 0) == subgraph)
97+
98+
#expect(1 == 2)
99+
}
100+
101+
@Test
102+
func addChildWithTag() {
103+
let graph = Graph()
104+
let subgraph = Subgraph(graph: graph)
105+
let child = Subgraph(graph: graph)
106+
107+
subgraph.addChild(child, tag: 1)
108+
#expect(subgraph.childCount == 1)
109+
#expect(subgraph.isAncestor(of: child) == true)
110+
111+
var tag = 0
112+
#expect(subgraph.child(at: 0, tag: &tag) == child)
113+
#expect(tag == 1)
114+
115+
#expect(child.parentCount == 1)
116+
#expect(child.parent(at: 0) == subgraph)
117+
}
118+
119+
@Test
120+
func removeChild() {
121+
let graph = Graph()
122+
let subgraph = Subgraph(graph: graph)
123+
let child = Subgraph(graph: graph)
124+
125+
subgraph.addChild(child)
126+
subgraph.removeChild(child)
127+
#expect(subgraph.childCount == 0)
128+
#expect(subgraph.isAncestor(of: child) == false)
129+
130+
#expect(child.parentCount == 0)
131+
}
132+
133+
}
79134
}

0 commit comments

Comments
 (0)