diff --git a/Sources/FoundationEssentials/ProcessInfo/ProcessInfo.swift b/Sources/FoundationEssentials/ProcessInfo/ProcessInfo.swift index acb94408e..51509a557 100644 --- a/Sources/FoundationEssentials/ProcessInfo/ProcessInfo.swift +++ b/Sources/FoundationEssentials/ProcessInfo/ProcessInfo.swift @@ -229,7 +229,7 @@ final class _ProcessInfo: Sendable { _ = GetUserNameExW(NameDisplay, nil, &ulLength) return withUnsafeTemporaryAllocation(of: WCHAR.self, capacity: Int(ulLength)) { wszBuffer in - guard GetUserNameExW(NameDisplay, wszBuffer.baseAddress!, &ulLength) == 0 else { + guard GetUserNameExW(NameDisplay, wszBuffer.baseAddress!, &ulLength) != 0 else { return "" } return String(decoding: wszBuffer.prefix(Int(ulLength)), as: UTF16.self) diff --git a/Tests/FoundationEssentialsTests/ProcessInfoTests.swift b/Tests/FoundationEssentialsTests/ProcessInfoTests.swift index 2dfe31ce0..2e98f308d 100644 --- a/Tests/FoundationEssentialsTests/ProcessInfoTests.swift +++ b/Tests/FoundationEssentialsTests/ProcessInfoTests.swift @@ -147,7 +147,7 @@ private struct ProcessInfoTests { "ProcessInfo thinks we are on System 70") } -#if os(macOS) +#if canImport(Darwin) || os(Windows) @Test func userName() { #expect(!ProcessInfo.processInfo.userName.isEmpty) }