mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
- Removed unnecessary #if guard - Used IOReturn instead of Int32 return type - Avoided private access control for overlays - Added a test to ensure the type of the constants matches the return type of a IOKit function
32 lines
876 B
Swift
32 lines
876 B
Swift
// RUN: %target-run-simple-swift
|
|
// REQUIRES: executable_test
|
|
// REQUIRES: OS=macosx
|
|
|
|
import IOKit
|
|
import IOKit.hid
|
|
import StdlibUnittest
|
|
|
|
// Also import modules which are used by StdlibUnittest internally. This
|
|
// workaround is needed to link all required libraries in case we compile
|
|
// StdlibUnittest with -sil-serialize-all.
|
|
import SwiftPrivate
|
|
#if _runtime(_ObjC)
|
|
import ObjectiveC
|
|
#endif
|
|
|
|
var IOKitTests = TestSuite("IOKit")
|
|
|
|
IOKitTests.test("IOReturn value") {
|
|
// Error codes are computed by a helper function so it's enough to test one.
|
|
// The value is taken from the OS X 10.11 SDK.
|
|
expectEqual(Int(kIOReturnStillOpen), -536870190)
|
|
}
|
|
|
|
IOKitTests.test("IOReturn type") {
|
|
let manager = IOHIDManagerCreate(nil, 0)!.takeRetainedValue()
|
|
let result = IOHIDManagerClose(manager, 0)
|
|
expectTrue(result.dynamicType == kIOReturnNotOpen.dynamicType)
|
|
}
|
|
|
|
runAllTests()
|