From b0530d6bc367290be0f4babdc47782650450bc0e Mon Sep 17 00:00:00 2001 From: Alsey Coleman Miller Date: Mon, 11 Mar 2024 14:59:51 -0400 Subject: [PATCH] Updated unit tests --- Tests/BluetoothTests/UInt24Tests.swift | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Tests/BluetoothTests/UInt24Tests.swift b/Tests/BluetoothTests/UInt24Tests.swift index 1cb840593..58e5b7042 100644 --- a/Tests/BluetoothTests/UInt24Tests.swift +++ b/Tests/BluetoothTests/UInt24Tests.swift @@ -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) + } }