From 523711061ba81ca32747261edfbc7e4d8b618b10 Mon Sep 17 00:00:00 2001 From: Norio Nomura Date: Fri, 14 Oct 2016 18:10:47 +0900 Subject: [PATCH] Remove surplus assertions from triggeringExamples Removed: - Comparing total count of violations and expected locations from all triggering examples - Comparing count of violations and expected locations on each triggering examples - Order based comparison between violations and expected locations --- Tests/SwiftLintFrameworkTests/TestHelpers.swift | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/Tests/SwiftLintFrameworkTests/TestHelpers.swift b/Tests/SwiftLintFrameworkTests/TestHelpers.swift index ea40cfc96..4b92b1a32 100644 --- a/Tests/SwiftLintFrameworkTests/TestHelpers.swift +++ b/Tests/SwiftLintFrameworkTests/TestHelpers.swift @@ -145,23 +145,17 @@ extension XCTestCase { } // Triggering examples violate - var violationsCount = 0 - var expectedViolationsCount = 0 for trigger in triggers { - let triggerViolations = violations(trigger, config: config).sorted { - $0.location < $1.location - } - violationsCount += triggerViolations.count + let triggerViolations = violations(trigger, config: config) + // Triggering examples with violation markers violate at the marker's location let (cleanTrigger, markerOffsets) = cleanedContentsAndMarkerOffsets(from: trigger) if markerOffsets.isEmpty { if triggerViolations.isEmpty { XCTFail("triggeringExample did not violate: \n```\n\(trigger)\n```") } - expectedViolationsCount += 1 continue } - expectedViolationsCount += markerOffsets.count let file = File(contents: cleanTrigger) let expectedLocations = markerOffsets.map { Location(file: file, characterOffset: $0) } @@ -172,6 +166,7 @@ extension XCTestCase { XCTFail("triggeringExample violate at unexpected location: \n" + "\(render(violations: violationsAtUnexpectedLocation, in: trigger))") } + // Assert locations missing vaiolation let violatedLocations = triggerViolations.map { $0.location } let locationsWithoutViolation = expectedLocations.filter { !violatedLocations.contains($0) } @@ -186,7 +181,6 @@ extension XCTestCase { "'\(trigger)' violation didn't match expected location.") } } - XCTAssertEqual(violationsCount, expectedViolationsCount) // Comment doesn't violate XCTAssertEqual(