Skip to content

Commit

Permalink
Updated unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
colemancda committed Mar 2, 2024
1 parent 43be2d5 commit 372fd17
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ var package = Package(
name: "BluetoothGATT",
package: "Bluetooth"
),
.product(
name: "BluetoothGAP",
package: "Bluetooth"
)
]
)
]
Expand Down
18 changes: 18 additions & 0 deletions Tests/BluetoothLinuxTests/L2CAPTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import XCTest
import Bluetooth
import BluetoothHCI
import BluetoothGATT
import BluetoothGAP
@testable import BluetoothLinux

final class L2CAPTests: XCTestCase {
Expand All @@ -22,6 +23,23 @@ final class L2CAPTests: XCTestCase {
XCTFail()
return
}
do {
do { try await controller.enableLowEnergyAdvertising(false) }
catch HCIError.commandDisallowed { /* ignore */ }

let encoder = GAPDataEncoder()
let advertisingData = try encoder.encodeAdvertisingData([
GAPShortLocalName(name: "Test")
])
try await controller.setLowEnergyAdvertisingData(advertisingData)

do { try await controller.enableLowEnergyAdvertising() }
catch HCIError.commandDisallowed { /* ignore */ }
}
catch {
NSLog("Unable to enable advertising. \(error)")
}
NSLog("Enabled advertising")
let address = try await controller.readDeviceAddress()
NSLog("Will create server socket \(address)")
let serverSocket = try await BluetoothLinux.L2CAPSocket.lowEnergyServer(
Expand Down

0 comments on commit 372fd17

Please sign in to comment.