mirror of
https://github.com/realm/SwiftLint.git
synced 2026-06-06 20:18:40 +00:00
0335f155ab
Fixes #183.
69 lines
2.3 KiB
Swift
69 lines
2.3 KiB
Swift
//
|
|
// ReporterTests.swift
|
|
// SwiftLint
|
|
//
|
|
// Created by JP Simard on 9/19/15.
|
|
// Copyright © 2015 Realm. All rights reserved.
|
|
//
|
|
|
|
import SwiftLintFramework
|
|
import XCTest
|
|
|
|
class ReporterTests: XCTestCase {
|
|
func generateViolations() -> [StyleViolation] {
|
|
let location = Location(file: "filename", line: 1, character: 2)
|
|
return [
|
|
StyleViolation(ruleDescription: LineLengthRule.description,
|
|
location: location,
|
|
reason: "Violation Reason."),
|
|
StyleViolation(ruleDescription: LineLengthRule.description,
|
|
severity: .Error,
|
|
location: location,
|
|
reason: "Violation Reason.")
|
|
]
|
|
}
|
|
|
|
func testXcodeReporter() {
|
|
XCTAssertEqual(
|
|
XcodeReporter.generateReport(generateViolations()),
|
|
"filename:1:2: warning: Line Length Violation: Violation Reason. (line_length)\n" +
|
|
"filename:1:2: error: Line Length Violation: Violation Reason. (line_length)"
|
|
)
|
|
}
|
|
|
|
func testJSONReporter() {
|
|
XCTAssertEqual(
|
|
JSONReporter.generateReport(generateViolations()),
|
|
"[\n" +
|
|
" {\n" +
|
|
" \"reason\" : \"Violation Reason.\",\n" +
|
|
" \"character\" : 2,\n" +
|
|
" \"file\" : \"filename\",\n" +
|
|
" \"rule_id\" : \"line_length\",\n" +
|
|
" \"line\" : 1,\n" +
|
|
" \"severity\" : \"Warning\",\n" +
|
|
" \"type\" : \"Line Length\"\n" +
|
|
" },\n" +
|
|
" {\n" +
|
|
" \"reason\" : \"Violation Reason.\",\n" +
|
|
" \"character\" : 2,\n" +
|
|
" \"file\" : \"filename\",\n" +
|
|
" \"rule_id\" : \"line_length\",\n" +
|
|
" \"line\" : 1,\n" +
|
|
" \"severity\" : \"Error\",\n" +
|
|
" \"type\" : \"Line Length\"\n" +
|
|
" }\n" +
|
|
"]"
|
|
)
|
|
}
|
|
|
|
func testCSVReporter() {
|
|
XCTAssertEqual(
|
|
CSVReporter.generateReport(generateViolations()),
|
|
"file,line,character,severity,type,reason,rule_id," +
|
|
"filename,1,2,Warning,Line Length,Violation Reason.,line_length," +
|
|
"filename,1,2,Error,Line Length,Violation Reason.,line_length"
|
|
)
|
|
}
|
|
}
|