|
1 | 1 | /*
|
2 | 2 | This source file is part of the Swift.org open source project
|
3 | 3 |
|
4 |
| - Copyright (c) 2021 Apple Inc. and the Swift project authors |
| 4 | + Copyright (c) 2021-2022 Apple Inc. and the Swift project authors |
5 | 5 | Licensed under Apache License v2.0 with Runtime Library Exception
|
6 | 6 |
|
7 | 7 | See https://swift.org/LICENSE.txt for license information
|
@@ -31,6 +31,39 @@ class NonInclusiveLanguageCheckerTests: XCTestCase {
|
31 | 31 | XCTAssertEqual(range.upperBound.column, 16)
|
32 | 32 | }
|
33 | 33 |
|
| 34 | + func testMatchTermWithSpaces() throws { |
| 35 | + let source = """ |
| 36 | + # A White listed title |
| 37 | + # A Black listed title |
| 38 | + # A White listed title |
| 39 | + """ |
| 40 | + let document = Document(parsing: source) |
| 41 | + var checker = NonInclusiveLanguageChecker(sourceFile: nil) |
| 42 | + checker.visit(document) |
| 43 | + XCTAssertEqual(checker.problems.count, 3) |
| 44 | + |
| 45 | + let problem = try XCTUnwrap(checker.problems.first) |
| 46 | + let range = try XCTUnwrap(problem.diagnostic.range) |
| 47 | + XCTAssertEqual(range.lowerBound.line, 1) |
| 48 | + XCTAssertEqual(range.lowerBound.column, 5) |
| 49 | + XCTAssertEqual(range.upperBound.line, 1) |
| 50 | + XCTAssertEqual(range.upperBound.column, 18) |
| 51 | + |
| 52 | + let problemTwo = try XCTUnwrap(checker.problems[1]) |
| 53 | + let rangeTwo = try XCTUnwrap(problemTwo.diagnostic.range) |
| 54 | + XCTAssertEqual(rangeTwo.lowerBound.line, 2) |
| 55 | + XCTAssertEqual(rangeTwo.lowerBound.column, 5) |
| 56 | + XCTAssertEqual(rangeTwo.upperBound.line, 2) |
| 57 | + XCTAssertEqual(rangeTwo.upperBound.column, 20) |
| 58 | + |
| 59 | + let problemThree = try XCTUnwrap(checker.problems[2]) |
| 60 | + let rangeThree = try XCTUnwrap(problemThree.diagnostic.range) |
| 61 | + XCTAssertEqual(rangeThree.lowerBound.line, 3) |
| 62 | + XCTAssertEqual(rangeThree.lowerBound.column, 5) |
| 63 | + XCTAssertEqual(rangeThree.upperBound.line, 3) |
| 64 | + XCTAssertEqual(rangeThree.upperBound.column, 17) |
| 65 | + } |
| 66 | + |
34 | 67 | func testMatchTermInAbstract() throws {
|
35 | 68 | let source = """
|
36 | 69 | # Title
|
|
0 commit comments