|
7 | 7 | // See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
|
8 | 8 | //
|
9 | 9 |
|
| 10 | +import CoreFoundation |
| 11 | + |
10 | 12 | class TestNSArray : XCTestCase {
|
11 | 13 |
|
12 | 14 | static var allTests: [(String, (TestNSArray) -> () throws -> Void)] {
|
@@ -42,6 +44,7 @@ class TestNSArray : XCTestCase {
|
42 | 44 | ("test_insertObjectsAtIndexes", test_insertObjectsAtIndexes),
|
43 | 45 | ("test_replaceObjectsAtIndexesWithObjects", test_replaceObjectsAtIndexesWithObjects),
|
44 | 46 | ("test_pathsMatchingExtensions", test_pathsMatchingExtensions),
|
| 47 | + ("test_arrayUsedAsCFArrayInvokesArrayMethods", test_arrayUsedAsCFArrayInvokesArrayMethods), |
45 | 48 | ]
|
46 | 49 | }
|
47 | 50 |
|
@@ -794,6 +797,14 @@ class TestNSArray : XCTestCase {
|
794 | 797 | XCTAssertEqual(match5, [])
|
795 | 798 | }
|
796 | 799 |
|
| 800 | + func test_arrayUsedAsCFArrayInvokesArrayMethods() { |
| 801 | + let number = 789 as NSNumber |
| 802 | + let array = NSMutableArray(array: [123, 456]) |
| 803 | + CFArraySetValueAtIndex(unsafeBitCast(array, to: CFMutableArray.self), 1, UnsafeRawPointer(Unmanaged.passUnretained(number).toOpaque())) |
| 804 | + XCTAssertEqual(array[0] as! NSNumber, 123 as NSNumber) |
| 805 | + XCTAssertEqual(array[1] as! NSNumber, 789 as NSNumber) |
| 806 | + } |
| 807 | + |
797 | 808 | private func createTestFile(_ path: String, _contents: Data) -> String? {
|
798 | 809 | let tempDir = NSTemporaryDirectory() + "TestFoundation_Playground_" + NSUUID().uuidString + "/"
|
799 | 810 | do {
|
|
0 commit comments