Files
swift-mirror/test/stdlib/WinSDK_GUID.swift
Jonathan Grynspan 5846e8f6a4 Add Equatable and Hashable conformance to GUID. (#84792)
On Windows, `GUID` is a currency type and (along with its various
typedefs) is used pervasively Windows offers `IsEqualGUID()` and
`UuidHash()` for comparing and hashing them, respectively, but
`IsEqualGUID()` is a macro in C mode and `UuidHash()` only provides a
16-bit hash. We should provide conformance to these protocols in the
WinSDK overlay to provide equivalent functionality in Swift.
2025-10-10 08:34:34 -04:00

23 lines
570 B
Swift

// RUN: %target-build-swift %s -o %t.exe
// RUN: %target-codesign %t.exe
// RUN: %target-run %t.exe
// REQUIRES: executable_test
// REQUIRES: OS=windows-msvc
// Make sure that importing WinSDK brings in the GUID type, which is declared in
// /shared and not in /um.
import WinSDK
public func usesGUID(_ x: GUID) {}
// Make sure equating and hashing GUIDs works.
let guid: GUID = GUID_NULL
assert(guid == guid)
assert(guid.hashValue == guid.hashValue)
let guid2: GUID = IID_IUnknown
assert(guid != guid2)
assert(guid.hashValue != guid2.hashValue) // well, probably