diff --git a/Sources/HeapModule/Heap+Invariants.swift b/Sources/HeapModule/Heap+Invariants.swift index 0a350438..a3249b55 100644 --- a/Sources/HeapModule/Heap+Invariants.swift +++ b/Sources/HeapModule/Heap+Invariants.swift @@ -31,7 +31,7 @@ extension Heap { /// contents satisfy the min-max heap property. @inlinable @inline(never) - internal func _checkInvariants() { + public func _checkInvariants() { guard count > 1 else { return } _checkInvariants(node: .root, min: nil, max: nil) } diff --git a/Tests/HeapTests/HeapTests.swift b/Tests/HeapTests/HeapTests.swift index 473af1ed..3ba8881e 100644 --- a/Tests/HeapTests/HeapTests.swift +++ b/Tests/HeapTests/HeapTests.swift @@ -43,6 +43,13 @@ extension Heap { } final class HeapTests: CollectionTestCase { + func test_checkInvariants() { + // This test uses a plain `import HeapModule`, so it only compiles with + // COLLECTIONS_INTERNAL_CHECKS if `_checkInvariants()` is public there too. + let heap = Heap([3, 1, 4, 1, 5, 9, 2, 6]) + heap._checkInvariants() + } + func test_isEmpty() { var heap = Heap() expectTrue(heap.isEmpty)