13
13
//===----------------------------------------------------------------------===//
14
14
15
15
@testable import CoreMetrics
16
- @ testable import MetricsTestKit
16
+ import MetricsTestKit
17
17
import XCTest
18
18
19
19
class MetricsTests : XCTestCase {
@@ -49,7 +49,7 @@ class MetricsTests: XCTestCase {
49
49
Counter ( label: name) . increment ( by: value)
50
50
let counter = try metrics. expectCounter ( name)
51
51
XCTAssertEqual ( counter. values. count, 1 , " expected number of entries to match " )
52
- XCTAssertEqual ( counter. values [ 0 ] . 1 , Int64 ( value) , " expected value to match " )
52
+ XCTAssertEqual ( counter. values [ 0 ] , Int64 ( value) , " expected value to match " )
53
53
counter. reset ( )
54
54
XCTAssertEqual ( counter. values. count, 0 , " expected number of entries to match " )
55
55
}
@@ -112,7 +112,7 @@ class MetricsTests: XCTestCase {
112
112
fpCounter. increment ( by: Double ( sign: . plus, exponent: 63 , significand: 1 ) )
113
113
// Much larger than Int64
114
114
fpCounter. increment ( by: Double . greatestFiniteMagnitude)
115
- let values = counter. values. map { $0 . 1 }
115
+ let values = counter. values
116
116
XCTAssertEqual ( values. count, 2 , " expected number of entries to match " )
117
117
XCTAssertEqual ( values, [ Int64 . max, Int64 . max] , " expected extremely large values to be replaced with Int64.max " )
118
118
}
@@ -132,15 +132,15 @@ class MetricsTests: XCTestCase {
132
132
133
133
// Increment by a small value that should grow the accumulated buffer past 1.0 (perfectly representable)
134
134
fpCounter. increment ( by: 1.5 )
135
- var values = counter. values. map { $0 . 1 }
135
+ var values = counter. values
136
136
XCTAssertEqual ( values. count, 1 , " expected number of entries to match " )
137
137
XCTAssertEqual ( values, [ 2 ] , " expected entries to match " )
138
138
XCTAssertEqual ( rawFpCounter. fraction, 0.25 , " " )
139
139
140
140
// Increment by a large value that should leave a fraction in the accumulator
141
141
// 1110506744053.76
142
142
fpCounter. increment ( by: Double ( sign: . plus, exponent: 40 , significand: 1.01 ) )
143
- values = counter. values. map { $0 . 1 }
143
+ values = counter. values
144
144
XCTAssertEqual ( values. count, 2 , " expected number of entries to match " )
145
145
XCTAssertEqual ( values, [ 2 , 1_110_506_744_054 ] , " expected entries to match " )
146
146
XCTAssertEqual ( rawFpCounter. fraction, 0.010009765625 , " expected fractional accumulated value " )
@@ -178,7 +178,7 @@ class MetricsTests: XCTestCase {
178
178
}
179
179
XCTAssertEqual ( values. count, testRecorder. values. count, " expected number of entries to match " )
180
180
for i in 0 ... values. count - 1 {
181
- XCTAssertEqual ( Int32 ( testRecorder. values [ i] . 1 ) , values [ i] , " expected value # \( i) to match. " )
181
+ XCTAssertEqual ( Int32 ( testRecorder. values [ i] ) , values [ i] , " expected value # \( i) to match. " )
182
182
}
183
183
}
184
184
@@ -194,7 +194,7 @@ class MetricsTests: XCTestCase {
194
194
}
195
195
XCTAssertEqual ( values. count, testRecorder. values. count, " expected number of entries to match " )
196
196
for i in 0 ... values. count - 1 {
197
- XCTAssertEqual ( Float ( testRecorder. values [ i] . 1 ) , values [ i] , " expected value # \( i) to match. " )
197
+ XCTAssertEqual ( Float ( testRecorder. values [ i] ) , values [ i] , " expected value # \( i) to match. " )
198
198
}
199
199
}
200
200
@@ -373,7 +373,7 @@ class MetricsTests: XCTestCase {
373
373
meter. set ( value)
374
374
let testMeter = meter. _handler as! TestMeter
375
375
XCTAssertEqual ( testMeter. values. count, 1 , " expected number of entries to match " )
376
- XCTAssertEqual ( testMeter. values [ 0 ] . 1 , value, " expected value to match " )
376
+ XCTAssertEqual ( testMeter. values [ 0 ] , value, " expected value to match " )
377
377
}
378
378
379
379
func testMeterBlock( ) throws {
@@ -386,7 +386,7 @@ class MetricsTests: XCTestCase {
386
386
Meter ( label: name) . set ( value)
387
387
let testMeter = try metrics. expectMeter ( name)
388
388
XCTAssertEqual ( testMeter. values. count, 1 , " expected number of entries to match " )
389
- XCTAssertEqual ( testMeter. values [ 0 ] . 1 , value, " expected value to match " )
389
+ XCTAssertEqual ( testMeter. values [ 0 ] , value, " expected value to match " )
390
390
}
391
391
392
392
func testMUX_Counter( ) throws {
@@ -424,7 +424,7 @@ class MetricsTests: XCTestCase {
424
424
let meter = factory. meters. first
425
425
XCTAssertEqual ( meter? . label, name, " expected label to match " )
426
426
XCTAssertEqual ( meter? . values. count, 1 , " expected number of entries to match " )
427
- XCTAssertEqual ( meter? . values [ 0 ] . 1 , value, " expected value to match " )
427
+ XCTAssertEqual ( meter? . values [ 0 ] , value, " expected value to match " )
428
428
}
429
429
}
430
430
@@ -441,7 +441,7 @@ class MetricsTests: XCTestCase {
441
441
let recorder = factory. recorders. first
442
442
XCTAssertEqual ( recorder? . label, name, " expected label to match " )
443
443
XCTAssertEqual ( recorder? . values. count, 1 , " expected number of entries to match " )
444
- XCTAssertEqual ( recorder? . values [ 0 ] . 1 , value, " expected value to match " )
444
+ XCTAssertEqual ( recorder? . values [ 0 ] , value, " expected value to match " )
445
445
}
446
446
}
447
447
@@ -460,7 +460,7 @@ class MetricsTests: XCTestCase {
460
460
XCTAssertEqual ( timer? . values. count, 1 , " expected number of entries to match " )
461
461
XCTAssertEqual ( timer? . values [ 0 ] , Int64 ( seconds * 1_000_000_000 ) , " expected value to match " )
462
462
XCTAssertEqual ( timer? . displayUnit, . minutes, " expected value to match " )
463
- XCTAssertEqual ( timer? . retrieveValueInPreferredUnit ( atIndex: 0 ) , Double ( seconds) / 60.0 , " seconds should be returned as minutes " )
463
+ XCTAssertEqual ( timer? . valueInPreferredUnit ( atIndex: 0 ) , Double ( seconds) / 60.0 , " seconds should be returned as minutes " )
464
464
}
465
465
}
466
466
@@ -488,7 +488,7 @@ class MetricsTests: XCTestCase {
488
488
489
489
let recorder = gauge. _handler as! TestRecorder
490
490
XCTAssertEqual ( recorder. values. count, 1 , " expected number of entries to match " )
491
- XCTAssertEqual ( recorder. values. first! . 1 , value, " expected value to match " )
491
+ XCTAssertEqual ( recorder. values. first, value, " expected value to match " )
492
492
XCTAssertEqual ( metrics. recorders. count, 1 , " recorder should have been stored " )
493
493
494
494
let identity = ObjectIdentifier ( recorder)
@@ -500,7 +500,7 @@ class MetricsTests: XCTestCase {
500
500
501
501
let recorderAgain = gaugeAgain. _handler as! TestRecorder
502
502
XCTAssertEqual ( recorderAgain. values. count, 1 , " expected number of entries to match " )
503
- XCTAssertEqual ( recorderAgain. values. first! . 1 , - value, " expected value to match " )
503
+ XCTAssertEqual ( recorderAgain. values. first, - value, " expected value to match " )
504
504
505
505
let identityAgain = ObjectIdentifier ( recorderAgain)
506
506
XCTAssertNotEqual ( identity, identityAgain, " since the cached metric was released, the created a new should have a different identity " )
@@ -518,7 +518,7 @@ class MetricsTests: XCTestCase {
518
518
519
519
let testMeter = meter. _handler as! TestMeter
520
520
XCTAssertEqual ( testMeter. values. count, 1 , " expected number of entries to match " )
521
- XCTAssertEqual ( testMeter. values. first! . 1 , value, " expected value to match " )
521
+ XCTAssertEqual ( testMeter. values. first, value, " expected value to match " )
522
522
XCTAssertEqual ( metrics. meters. count, 1 , " recorder should have been stored " )
523
523
524
524
let identity = ObjectIdentifier ( testMeter)
@@ -530,7 +530,7 @@ class MetricsTests: XCTestCase {
530
530
531
531
let testMeterAgain = meterAgain. _handler as! TestMeter
532
532
XCTAssertEqual ( testMeterAgain. values. count, 1 , " expected number of entries to match " )
533
- XCTAssertEqual ( testMeterAgain. values. first! . 1 , - value, " expected value to match " )
533
+ XCTAssertEqual ( testMeterAgain. values. first, - value, " expected value to match " )
534
534
535
535
let identityAgain = ObjectIdentifier ( testMeterAgain)
536
536
XCTAssertNotEqual ( identity, identityAgain, " since the cached metric was released, the created a new should have a different identity " )
@@ -548,7 +548,7 @@ class MetricsTests: XCTestCase {
548
548
549
549
let testCounter = counter. _handler as! TestCounter
550
550
XCTAssertEqual ( testCounter. values. count, 1 , " expected number of entries to match " )
551
- XCTAssertEqual ( testCounter. values. first! . 1 , Int64 ( value) , " expected value to match " )
551
+ XCTAssertEqual ( testCounter. values. first, Int64 ( value) , " expected value to match " )
552
552
XCTAssertEqual ( metrics. counters. count, 1 , " counter should have been stored " )
553
553
554
554
let identity = ObjectIdentifier ( counter)
@@ -560,7 +560,7 @@ class MetricsTests: XCTestCase {
560
560
561
561
let testCounterAgain = counterAgain. _handler as! TestCounter
562
562
XCTAssertEqual ( testCounterAgain. values. count, 1 , " expected number of entries to match " )
563
- XCTAssertEqual ( testCounterAgain. values. first! . 1 , Int64 ( value) , " expected value to match " )
563
+ XCTAssertEqual ( testCounterAgain. values. first, Int64 ( value) , " expected value to match " )
564
564
565
565
let identityAgain = ObjectIdentifier ( counterAgain)
566
566
XCTAssertNotEqual ( identity, identityAgain, " since the cached metric was released, the created a new should have a different identity " )
0 commit comments