@@ -17,37 +17,59 @@ import XCTest
17
17
@testable import Benchmark
18
18
19
19
final class BenchmarkReporterTests : XCTestCase {
20
- func assertConsoleReported( _ results: [ BenchmarkResult ] , _ expected: String ) {
20
+ func assertConsoleReported(
21
+ _ results: [ BenchmarkResult ] ,
22
+ _ expected: String ,
23
+ _ message: @autoclosure ( ) -> String = " " ,
24
+ file: StaticString = #filePath,
25
+ line: UInt = #line
26
+ ) {
21
27
let output = MockTextOutputStream ( )
22
28
var reporter = ConsoleReporter ( output: output)
23
29
reporter. report ( results: results)
24
- assertReported ( output. result ( ) , expected)
30
+ assertReported ( output. result ( ) , expected, message ( ) , file : file , line : line )
25
31
}
26
32
27
- func assertJSONReported( _ results: [ BenchmarkResult ] , _ expected: String ) {
33
+ func assertJSONReported(
34
+ _ results: [ BenchmarkResult ] ,
35
+ _ expected: String ,
36
+ _ message: @autoclosure ( ) -> String = " " ,
37
+ file: StaticString = #filePath,
38
+ line: UInt = #line
39
+ ) {
28
40
let output = MockTextOutputStream ( )
29
41
var reporter = JSONReporter ( output: output)
30
42
reporter. report ( results: results)
31
- assertReported ( output. result ( ) , expected)
43
+ assertReported ( output. result ( ) , expected, message ( ) , file : file , line : line )
32
44
}
33
45
34
46
func assertCSVReported(
35
- _ results: [ BenchmarkResult ] , _ expected: String
47
+ _ results: [ BenchmarkResult ] ,
48
+ _ expected: String ,
49
+ _ message: @autoclosure ( ) -> String = " " ,
50
+ file: StaticString = #filePath,
51
+ line: UInt = #line
36
52
) {
37
53
let output = MockTextOutputStream ( )
38
54
var reporter = CSVReporter ( output: output)
39
55
reporter. report ( results: results)
40
- assertReported ( output. result ( ) , expected)
56
+ assertReported ( output. result ( ) , expected, message ( ) , file : file , line : line )
41
57
}
42
58
43
- func assertReported( _ got: String , _ expected: String ) {
59
+ func assertReported(
60
+ _ got: String ,
61
+ _ expected: String ,
62
+ _ message: @autoclosure ( ) -> String = " " ,
63
+ file: StaticString = #filePath,
64
+ line: UInt = #line
65
+ ) {
44
66
let lines = Array ( got. split ( separator: " \n " ) . map { String ( $0) } )
45
67
let expectedLines = expected. split ( separator: " \n " ) . map { String ( $0) }
46
68
let actual = lines. map { $0. trimmingCharacters ( in: . newlines) }
47
69
. filter { !$0. isEmpty }
48
- XCTAssertEqual ( expectedLines. count, actual. count)
70
+ XCTAssertEqual ( expectedLines. count, actual. count, message ( ) , file : file , line : line )
49
71
for (expectedLine, actualLine) in zip ( expectedLines, actual) {
50
- XCTAssertEqual ( expectedLine, actualLine)
72
+ XCTAssertEqual ( expectedLine, actualLine, message ( ) , file : file , line : line )
51
73
}
52
74
}
53
75
0 commit comments