-
-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prevent Duplicate CaptureGroup Registrations (#370)
- Loading branch information
1 parent
309466f
commit 577fc8d
Showing
2 changed files
with
40 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// | ||
// UniqueCaptureGroupTests.swift | ||
// xcbeautify | ||
// | ||
// Created by Charles Pisciotta on 2/9/25. | ||
// | ||
|
||
import XCTest | ||
@testable import XcbeautifyLib | ||
|
||
final class UniqueCaptureGroupTests: XCTestCase { | ||
private let captureGroupTypes = Parser().__for_test__captureGroupTypes() | ||
|
||
#if os(macOS) | ||
func testUniqueCaptureGroupRegistrations() { | ||
var seen = [any CaptureGroup.Type]() | ||
var duplicates = [any CaptureGroup.Type]() | ||
|
||
for type in captureGroupTypes { | ||
if seen.contains(where: { $0 == type }) { | ||
duplicates.append(type) | ||
} else { | ||
seen.append(type) | ||
} | ||
} | ||
|
||
XCTAssertEqual( | ||
duplicates.count, | ||
0, | ||
"Found the following duplicate CaptureGroup registration(s): \(ListFormatter.localizedString(byJoining: duplicates.map(String.init(describing:))))" | ||
) | ||
} | ||
#endif | ||
} |