Skip to content

Commit

Permalink
Updated unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
colemancda committed Sep 12, 2018
1 parent 251d6ef commit 464c023
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
12 changes: 8 additions & 4 deletions Tests/BluetoothTests/GATTTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,8 @@ final class GATTTests: XCTestCase {
server.writePending = {
do {
while try server.write() {
try client.read()
let didRead = try client.read()
XCTAssert(didRead)
}
}
catch { XCTFail("Error: \(error)") }
Expand All @@ -661,7 +662,8 @@ final class GATTTests: XCTestCase {
client.writePending = {
do {
while try client.write() {
try server.read()
let didRead = try server.read()
XCTAssert(didRead)
}
}
catch { XCTFail("Error: \(error)") }
Expand Down Expand Up @@ -1022,7 +1024,8 @@ extension GATTTests {

while server.socket.input.isEmpty == false {

try server.gatt.read()
let didRead = try server.gatt.read()
assert(didRead)
}

while try server.gatt.write() {
Expand All @@ -1032,7 +1035,8 @@ extension GATTTests {

while client.socket.input.isEmpty == false {

try client.gatt.read()
let didRead = try client.gatt.read()
assert(didRead)
}

} while didWrite
Expand Down
5 changes: 3 additions & 2 deletions Tests/BluetoothTests/L2CAPSocket.swift
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,11 @@ internal final class TestL2CAPSocket: L2CAPSocketProtocol {
}

/// Reads from the socket.
func recieve(_ bufferSize: Int) throws -> Data {
@discardableResult
func recieve(_ bufferSize: Int) throws -> Data? {

guard let sentData = self.input.popFirst()
else { throw POSIXError(code: .EBUSY) }
else { return nil }

let readData = Data(sentData.prefix(bufferSize))

Expand Down

0 comments on commit 464c023

Please sign in to comment.