Skip to content

Commit 4038189

Browse files
committed
test two-parameter withBorrowedName
1 parent f7e483f commit 4038189

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

Tests/SystemTests/MachPortTests.swift

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,22 @@ final class MachPortTests: XCTestCase {
194194
_ = send.relinquish()
195195
}
196196
}
197+
198+
func testMakeReceivedRightFromExistingName() throws {
199+
var name = mach_port_name_t(MACH_PORT_NULL)
200+
var kr = mach_port_allocate(mach_task_self_, MACH_PORT_RIGHT_RECEIVE, &name)
201+
XCTAssertEqual(kr, KERN_SUCCESS)
202+
XCTAssertNotEqual(name, mach_port_name_t(MACH_PORT_NULL))
203+
let context = mach_port_context_t(arc4random())
204+
kr = mach_port_guard(mach_task_self_, name, context, 0)
205+
XCTAssertEqual(kr, KERN_SUCCESS)
206+
207+
let right = Mach.Port<Mach.ReceiveRight>(name: name, context: context)
208+
right.withBorrowedName {
209+
XCTAssertEqual(name, $0)
210+
XCTAssertEqual(context, $1)
211+
}
212+
}
197213
}
198214

199215
#endif

0 commit comments

Comments
 (0)