Skip to content

Commit 6d2dfd0

Browse files
authored
Update TupleTypeCompatibilityTests.swift
1 parent e17c6c9 commit 6d2dfd0

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

Tests/OpenGraphCompatibilityTests/Runtime/TupleTypeCompatibilityTests.swift

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,8 @@ struct UnsafeMutableTupleCompatibilityTests {
151151
}
152152

153153
@Test
154-
func buffer() {
154+
func stackBuffer() {
155+
// size <= 0x1000
155156
withUnsafeTuple(of: TupleType([T1.self, T2.self]), count: 1) { mutableTuple in
156157
let ref = T1()
157158
ref.a = 1
@@ -162,6 +163,26 @@ struct UnsafeMutableTupleCompatibilityTests {
162163
let t1 = tuple[0] as T1
163164
let t2 = tuple[1] as T2
164165

166+
#expect(t1 === ref)
167+
#expect(t1.a == 1)
168+
#expect(t2.a == 2)
169+
}
170+
171+
}
172+
173+
@Test
174+
func heapBuffer() {
175+
// size > 0x1000
176+
withUnsafeTuple(of: TupleType([T1.self, T2.self]), count: 512) { mutableTuple in
177+
let ref = T1()
178+
ref.a = 1
179+
mutableTuple.initialize(at: 0, to: ref)
180+
mutableTuple.initialize(at: 1, to: T2(a: 2))
181+
182+
let tuple = UnsafeTuple(type: mutableTuple.type, value: mutableTuple.value)
183+
let t1 = tuple[0] as T1
184+
let t2 = tuple[1] as T2
185+
165186
#expect(t1 === ref)
166187
#expect(t1.a == 1)
167188
#expect(t2.a == 2)

0 commit comments

Comments
 (0)