Skip to content

Commit

Permalink
Added unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
colemancda committed Dec 4, 2017
1 parent c7251ce commit 85eb8db
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions Tests/BluetoothTests/AttributeProtocolTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,19 @@ final class AttributeProtocolTests: XCTestCase {
XCTAssert(errorResponse.byteValue == data)
}

do {

let data: [UInt8] = [1, 16, 49, 0, 10]

guard let errorResponse = ATTErrorResponse(byteValue: data)
else { XCTFail("Could not parse"); return }

XCTAssert(errorResponse.requestOpcode == .ReadByGroupTypeRequest)
XCTAssert(errorResponse.attributeHandle == 49)
XCTAssert(errorResponse.errorCode == .AttributeNotFound)
XCTAssert(errorResponse.byteValue == data)
}

do {

let data: [UInt8] = [2, 23, 0]
Expand Down Expand Up @@ -155,6 +168,7 @@ final class AttributeProtocolTests: XCTestCase {
XCTAssert(Data(pdu.data[0].value) == BluetoothUUID(rawValue: uuidString)!.littleEndian.data)
XCTAssert(BluetoothUUID(littleEndian:
BluetoothUUID(data: Data(pdu.data[0].value))!).rawValue == uuidString)
XCTAssert(pdu.byteValue == data)
}

do {
Expand All @@ -168,6 +182,7 @@ final class AttributeProtocolTests: XCTestCase {
XCTAssert(pdu.startHandle == 0x0001)
XCTAssert(pdu.endHandle == 0xFFFF)
XCTAssert(pdu.attributeValue == BluetoothUUID(rawValue: "C7A8D570-E023-4FB8-E511-72F9E24FF160")!.littleEndianData)
XCTAssert(pdu.byteValue == data)
}

do {
Expand All @@ -181,6 +196,7 @@ final class AttributeProtocolTests: XCTestCase {
XCTAssert(pdu.startHandle == 0x0001)
XCTAssert(pdu.endHandle == 0xFFFF)
XCTAssert(pdu.attributeValue == BluetoothUUID(rawValue: "60F14FE2-F972-11E5-B84F-23E070D5A8C7")!.littleEndianData)
XCTAssert(pdu.byteValue == data)
}

do {
Expand All @@ -196,6 +212,7 @@ final class AttributeProtocolTests: XCTestCase {

XCTAssert(foundHandle.foundAttribute == 40)
XCTAssert(foundHandle.groupEnd == 48)
XCTAssert(pdu.byteValue == data)
}
}
}

0 comments on commit 85eb8db

Please sign in to comment.