Skip to content

Commit

Permalink
Updated unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
colemancda committed Nov 11, 2024
1 parent 6becf2d commit deb68ae
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 44 deletions.
4 changes: 2 additions & 2 deletions Tests/BluetoothTests/GATTCharacteristicTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1356,7 +1356,7 @@ final class GATTCharacteristicTests: XCTestCase {

XCTAssertEqual(characteristic.data, data)
XCTAssertEqual(characteristic.date, GATTDateUTC.Day(rawValue: 16777214))
XCTAssertEqual(characteristic.description, "FFFFFE")
XCTAssertEqual(characteristic.description, "16777214")
XCTAssertEqual(GATTDateUTC.uuid, .dateUtc)
XCTAssertEqual(GATTDateUTC.Day.unitType, .day)
XCTAssertEqual(GATTDateUTC(data: data), GATTDateUTC(data: data))
Expand Down Expand Up @@ -1445,7 +1445,7 @@ final class GATTCharacteristicTests: XCTestCase {

XCTAssertEqual(characteristics.data, data)
XCTAssertEqual(UInt64(characteristics.rawValue), 281474976710655)
XCTAssertEqual(characteristics.description, "FFFFFFFFFFFF")
XCTAssertEqual(characteristics.description, "281474976710655")
XCTAssertEqual(GATTObjectID.uuid, .objectId)
XCTAssertEqual(GATTObjectID(data: data), GATTObjectID(data: data))
}
Expand Down
6 changes: 3 additions & 3 deletions Tests/BluetoothTests/GATTDescriptorTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ final class GATTDescriptorTests: XCTestCase {
clientConfiguration.insert(.notify)
XCTAssertEqual(clientConfiguration.data, Data([0x01, 00]))

XCTAssert(clientConfiguration.remove(.notify) == 0x0000)
XCTAssertEqual(clientConfiguration.remove(.notify), .notify)
XCTAssertEqual(clientConfiguration.data, Data([0x00, 0x00]))
XCTAssertEqual(clientConfiguration, [])
XCTAssertEqual(clientConfiguration.rawValue, 0)
Expand All @@ -57,7 +57,7 @@ final class GATTDescriptorTests: XCTestCase {
extendedProperties.insert(.reliableWrite)
XCTAssertEqual(extendedProperties.data, Data([0x01, 0x00]))

XCTAssert(extendedProperties.remove(.reliableWrite) == 0x0000)
XCTAssertEqual(extendedProperties.remove(.reliableWrite), .reliableWrite)
XCTAssertEqual(extendedProperties.data, Data([0x00, 0x00]))

XCTAssertEqual(extendedProperties, [])
Expand All @@ -81,7 +81,7 @@ final class GATTDescriptorTests: XCTestCase {
serverConfiguration.insert(.broadcasts)
XCTAssertEqual(serverConfiguration.data, Data([0x01]))

XCTAssert(serverConfiguration.remove(.broadcasts) == 0x00)
XCTAssertEqual(serverConfiguration.remove(.broadcasts), .broadcasts)
XCTAssertEqual(serverConfiguration.data, Data([0x00]))

XCTAssertEqual(serverConfiguration, [])
Expand Down
4 changes: 2 additions & 2 deletions Tests/BluetoothTests/GATTTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -787,13 +787,13 @@ final class GATTTests: XCTestCase {
// server
let serverAddress = BluetoothAddress.min
let clientAddress = BluetoothAddress.max
let serverSocket = try await TestL2CAPSocket.lowEnergyServer(
let serverSocket = try TestL2CAPSocket.lowEnergyServer(
address: serverAddress,
isRandom: false,
backlog: 1
)
let serverAcceptTask = Task<GATTServer, Error> {
let newConnection = try await serverSocket.accept()
let newConnection = try serverSocket.accept()
print("GATTServer: New connection")
return await GATTServer(
socket: newConnection,
Expand Down
2 changes: 1 addition & 1 deletion Tests/BluetoothTests/HCITests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1133,7 +1133,7 @@ final class HCITests: XCTestCase {
if #available(macOS 15, iOS 18, watchOS 11, tvOS 18, visionOS 2, *) {
XCTAssertEqual(longTermKey.description, "46979477079145919533008304147725609989")
} else {
XCTAssertEqual(longTermKey.description, "2357EB0D0C24D85A985764ECCBECEC05")
XCTAssertEqual(longTermKey.description, "0x2357EB0D0C24D85A985764ECCBECEC05")
}

do {
Expand Down
2 changes: 1 addition & 1 deletion Tests/BluetoothTests/UInt128Tests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ final class UInt128Tests: XCTestCase {
if #available(macOS 15, iOS 18, watchOS 11, tvOS 18, visionOS 2, *) {
XCTAssertEqual(number.description, "128858851431381903469711580150894012615")
} else {
XCTAssertEqual(number.description, "60F14FE2F97211E5B84F23E070D5A8C7")
XCTAssertEqual(number.description, "0x60F14FE2F97211E5B84F23E070D5A8C7")
}
}

Expand Down
16 changes: 7 additions & 9 deletions Tests/BluetoothTests/UInt24Tests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ final class UInt24Tests: XCTestCase {

func testHashable() {

XCTAssertEqual(UInt24.zero.hashValue, UInt32(UInt24.zero).hashValue)
XCTAssertEqual(UInt24.max.hashValue, UInt32(UInt24.max).hashValue)
XCTAssertNotEqual(UInt24.max.hashValue, 0)
}

Expand All @@ -61,13 +59,13 @@ final class UInt24Tests: XCTestCase {
func testExpressibleByIntegerLiteral() {

let values: [(UInt24, String)] = [
(.zero, "000000"),
(0x000000, "000000"),
(0x000001, "000001"),
(0x000020, "000020"),
(0xABCDEF, "ABCDEF"),
(16777215, "FFFFFF"),
(0xFFFFFF, "FFFFFF")
(.zero, "0"),
(0x000000, "0"),
(0x000001, "1"),
(0x000020, "32"),
(0xABCDEF, "11259375"),
(16777215, "16777215"),
(0xFFFFFF, "16777215")
]

values.forEach { XCTAssertEqual($0.description, $1) }
Expand Down
10 changes: 5 additions & 5 deletions Tests/BluetoothTests/UInt256Tests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ final class UInt256Tests: XCTestCase {
func testExpressibleByIntegerLiteral() {

let values: [(UInt256, String)] = [
(UInt256.zero, "0000000000000000000000000000000000000000000000000000000000000000"),
(0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000, "0000000000000000000000000000000000000000000000000000000000000000"),
(0x0000000000000000000000000000000000000000000000000000000000000001, "0000000000000000000000000000000000000000000000000000000000000001"),
(0x0000000000000000000000000000000000000000000000000000000000000020, "0000000000000000000000000000000000000000000000000000000000000020"),
(0x000000000000000000000000000000000000000000000000DCBABEBAAFDE0001, "000000000000000000000000000000000000000000000000DCBABEBAAFDE0001")
(UInt256.zero, "0x0000000000000000000000000000000000000000000000000000000000000000"),
(0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000, "0x0000000000000000000000000000000000000000000000000000000000000000"),
(0x0000000000000000000000000000000000000000000000000000000000000001, "0x0000000000000000000000000000000000000000000000000000000000000001"),
(0x0000000000000000000000000000000000000000000000000000000000000020, "0x0000000000000000000000000000000000000000000000000000000000000020"),
(0x000000000000000000000000000000000000000000000000DCBABEBAAFDE0001, "0x000000000000000000000000000000000000000000000000DCBABEBAAFDE0001")
]

values.forEach { XCTAssertEqual($0.description, $1) }
Expand Down
15 changes: 7 additions & 8 deletions Tests/BluetoothTests/UInt40Tests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,19 @@ final class UInt40Tests: XCTestCase {

func testHashable() {

XCTAssertEqual(UInt40.zero.hashValue, UInt64(UInt40.zero).hashValue)
XCTAssertEqual(UInt40.max.hashValue, UInt64(UInt40.max).hashValue)
XCTAssertNotEqual(UInt40.max.hashValue, UInt64.max.hashValue)
}

func testExpressibleByIntegerLiteral() {

let values: [(UInt40, String)] = [
(UInt40.zero, "0000000000"),
(0x0000000000, "0000000000"),
(0x0000000001, "0000000001"),
(0x0000000020, "0000000020"),
(0xFFFE9ABCDE, "FFFE9ABCDE"),
(1099511627775, "FFFFFFFFFF")
(UInt40.zero, "0"),
(0x0000000000, "0"),
(0x0000000001, "1"),
(0x0000000020, "32"),
(12345678, "12345678"),
(1099511627775, "1099511627775"),
(0xFFFFFFFFFF, "1099511627775")
]

values.forEach { XCTAssertEqual($0.description, $1) }
Expand Down
15 changes: 7 additions & 8 deletions Tests/BluetoothTests/UInt48Tests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,19 @@ final class UInt48Tests: XCTestCase {

func testHashable() {

XCTAssertEqual(UInt48.zero.hashValue, UInt64(UInt48.zero).hashValue)
XCTAssertEqual(UInt48.max.hashValue, UInt64(UInt48.max).hashValue)
XCTAssertNotEqual(UInt48.max.hashValue, 0)
}

func testExpressibleByIntegerLiteral() {

let values: [(UInt48, String)] = [
(UInt48.zero, "000000000000"),
(0x0000000000, "000000000000"),
(0x0000000001, "000000000001"),
(0x0000000020, "000000000020"),
(0xFFFE9ABCDE, "00FFFE9ABCDE"),
(281474976710655, "FFFFFFFFFFFF")
(.zero, "0"),
(0x0000000000, "0"),
(0x0000000001, "1"),
(0x0000000020, "32"),
(123456789, "123456789"),
(281474976710655, "281474976710655"),
(0xFFFFFFFFFFFF, "281474976710655")
]

values.forEach { XCTAssertEqual($0.description, $1) }
Expand Down
10 changes: 5 additions & 5 deletions Tests/BluetoothTests/UInt512Tests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ final class UInt512Tests: XCTestCase {
func testExpressibleByIntegerLiteral() {

let values: [(UInt512, String)] = [
(UInt512.zero, "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"),
(0x0, "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"),
(0x1, "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001"),
(0x20, "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020"),
(0xDCBABEBAAFDE0001, "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000DCBABEBAAFDE0001")
(UInt512.zero, "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"),
(0x0, "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"),
(0x1, "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001"),
(0x20, "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020"),
(0xDCBABEBAAFDE0001, "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000DCBABEBAAFDE0001")
]

values.forEach { XCTAssertEqual($0.description, $1) }
Expand Down

0 comments on commit deb68ae

Please sign in to comment.