Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: exPHAT/SwiftBluetooth
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 1.0.0
Choose a base ref
...
head repository: exPHAT/SwiftBluetooth
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
  • 1 commit
  • 1 file changed
  • 1 contributor

Commits on Apr 17, 2024

  1. Add test for access crash

    exPHAT committed Apr 17, 2024
    Copy the full SHA
    82395b9 View commit details
Showing with 19 additions and 0 deletions.
  1. +19 −0 Tests/SwiftBluetoothTests/DisconnectedPeripheralTests.swift
19 changes: 19 additions & 0 deletions Tests/SwiftBluetoothTests/DisconnectedPeripheralTests.swift
Original file line number Diff line number Diff line change
@@ -139,4 +139,23 @@ final class DisconnectedPeripheralTests: CentralPeripheralTestCase {
XCTAssertFalse(mockPeripheral.isConnected)
}
}

@available(iOS 13, macOS 10.15, watchOS 6.0, tvOS 13.0, *)
func testAccessDiscoveryDataAfterDisconnect() async throws {
try await withTimeout { [self] in
central = CentralManager()
try await central.waitUntilReady()
peripheral = await central.scanForPeripherals().first!
try await central.connect(peripheral, timeout: connectionTimeout)

// Disconnect to test if the internal reference is dropped (it should not)
try await central.cancelPeripheralConnection(peripheral)
XCTAssertTrue(peripheral.state == .disconnected)

// Request a new reference (should be the same as `peripheral`)
let newPeripheralReference = try XCTUnwrap(central.retrievePeripherals(withIdentifiers: [peripheral.identifier]).first)
XCTAssertNotNil(newPeripheralReference.discovery)
XCTAssert(newPeripheralReference === peripheral) // Note: reference comparison
}
}
}