File tree 2 files changed +31
-16
lines changed 2 files changed +31
-16
lines changed Original file line number Diff line number Diff line change 9
9
//
10
10
//===----------------------------------------------------------------------===//
11
11
12
- #if DEBUG
13
12
import XCTest
14
- @ testable import PriorityQueueModule
13
+ import PriorityQueueModule
15
14
16
15
final class HeapTests : XCTestCase {
17
16
func test_isEmpty( ) {
@@ -352,19 +351,6 @@ final class HeapTests: XCTestCase {
352
351
353
352
// MARK: -
354
353
355
- func test_levelCalculation( ) {
356
- // Check alternating min and max levels in the heap
357
- var isMin = true
358
- for exp in 0 ... 12 {
359
- // Check [2^exp, 2^(exp + 1))
360
- for offset in Int ( pow ( 2 , Double ( exp) ) - 1 ) ..< Int ( pow ( 2 , Double ( exp + 1 ) ) - 1 ) {
361
- let node = _Node ( offset: offset)
362
- XCTAssertEqual ( node. isMinLevel, isMin)
363
- }
364
- isMin. toggle ( )
365
- }
366
- }
367
-
368
354
func test_initializer_fromCollection( ) {
369
355
var heap = Heap ( ( 1 ... 20 ) . shuffled ( ) )
370
356
XCTAssertEqual ( heap. max ( ) , 20 )
@@ -407,4 +393,3 @@ final class HeapTests: XCTestCase {
407
393
XCTAssertEqual ( heap. popMax ( ) , 1 )
408
394
}
409
395
}
410
- #endif
Original file line number Diff line number Diff line change
1
+ //===----------------------------------------------------------------------===//
2
+ //
3
+ // This source file is part of the Swift Collections open source project
4
+ //
5
+ // Copyright (c) 2021 Apple Inc. and the Swift project authors
6
+ // Licensed under Apache License v2.0 with Runtime Library Exception
7
+ //
8
+ // See https://swift.org/LICENSE.txt for license information
9
+ //
10
+ //===----------------------------------------------------------------------===//
11
+
12
+ #if DEBUG // These unit tests need access to PriorityQueueModule internals
13
+ import XCTest
14
+ @testable import PriorityQueueModule
15
+
16
+ class NodeTests : XCTestCase {
17
+ func test_levelCalculation( ) {
18
+ // Check alternating min and max levels in the heap
19
+ var isMin = true
20
+ for exp in 0 ... 12 {
21
+ // Check [2^exp, 2^(exp + 1))
22
+ for offset in Int ( pow ( 2 , Double ( exp) ) - 1 ) ..< Int ( pow ( 2 , Double ( exp + 1 ) ) - 1 ) {
23
+ let node = _Node ( offset: offset)
24
+ XCTAssertEqual ( node. isMinLevel, isMin)
25
+ }
26
+ isMin. toggle ( )
27
+ }
28
+ }
29
+ }
30
+ #endif // DEBUG
You can’t perform that action at this time.
0 commit comments