From 051fd93754340d08054c7d9dbef05aa3c14f65a4 Mon Sep 17 00:00:00 2001 From: Khan Winter <35942988+thecoolwinter@users.noreply.github.com> Date: Tue, 2 Sep 2025 22:18:29 -0500 Subject: [PATCH] Maybe fix test extension on linux --- Tests/CBORTests/Extensions/Data+hexString.swift | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Tests/CBORTests/Extensions/Data+hexString.swift b/Tests/CBORTests/Extensions/Data+hexString.swift index af21869..4ec6d23 100644 --- a/Tests/CBORTests/Extensions/Data+hexString.swift +++ b/Tests/CBORTests/Extensions/Data+hexString.swift @@ -12,7 +12,14 @@ import Foundation #endif extension Data { + private static let hexAlphabet = Array("0123456789abcdef".unicodeScalars) + func hexString() -> String { - map { String(format: "%02hhX", $0) }.joined() + // I'd rather use: map { String(format: "%02hhX", $0) }.joined() + // but that doesn't compile on linux... + String(reduce(into: "".unicodeScalars) { result, value in + result.append(Self.hexAlphabet[Int(value / 0x10)]) + result.append(Self.hexAlphabet[Int(value % 0x10)]) + }) } } -- 2.51.2