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 11, 2024
1 parent 8cec535 commit b0530d6
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions Tests/BluetoothTests/UInt24Tests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,19 @@ final class UInt24Tests: XCTestCase {
XCTAssertEqual(UInt24(data: data), 16777215)
XCTAssertEqual(UInt24.max.data, data)
}

func testCodable() throws {

struct Value: Equatable, Hashable, Codable {
let id: UInt24
}

let value = Value(id: UInt24.max)
let encoder = JSONEncoder()
let data = try encoder.encode(value)
XCTAssertEqual(String(data: data, encoding: .utf8), #"{"id":16777215}"#)
let decoder = JSONDecoder()
let decodedValue = try decoder.decode(Value.self, from: data)
XCTAssertEqual(value, decodedValue)
}
}

0 comments on commit b0530d6

Please sign in to comment.