Update Format Workflow (#127)

* Update Format Workflow

* Update IdentifiedArrayTests.swift
This commit is contained in:
Stephen Celis
2020-05-22 13:08:00 -04:00
committed by GitHub
parent 6001603856
commit c77bb6ceaf
3 changed files with 14 additions and 7 deletions

View File

@@ -15,7 +15,7 @@ jobs:
run: brew install swift-format
- name: Format
run: make format
- uses: stefanzweifel/git-auto-commit-action@v4.1.6
- uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Run swift-format
branch: 'master'

View File

@@ -238,7 +238,8 @@ where Element: Identifiable, ID == Element.ID {
self.init([], id: \.id)
}
public mutating func replaceSubrange<C, R>(_ subrange: R, with newElements: C) where C : Collection, R : RangeExpression, Element == C.Element, Index == R.Bound {
public mutating func replaceSubrange<C, R>(_ subrange: R, with newElements: C)
where C: Collection, R: RangeExpression, Element == C.Element, Index == R.Bound {
let replacingIds = self.ids[subrange]
let newIds = newElements.map { $0.id }
ids.replaceSubrange(subrange, with: newIds)

View File

@@ -133,14 +133,20 @@ final class IdentifiedArrayTests: XCTestCase {
User(id: 2, name: "Blob Jr."),
]
array.replaceSubrange(0...1, with: [
User(id: 4, name: "Flob IV"),
User(id: 5, name: "Flob V")
])
array.replaceSubrange(
0...1,
with: [
User(id: 4, name: "Flob IV"),
User(id: 5, name: "Flob V"),
]
)
XCTAssertEqual(
array,
[User(id: 4, name: "Flob IV"), User(id: 5, name: "Flob V"), User(id: 1, name: "Blob"), User(id: 2, name: "Blob Jr.")]
[
User(id: 4, name: "Flob IV"), User(id: 5, name: "Flob V"), User(id: 1, name: "Blob"),
User(id: 2, name: "Blob Jr."),
]
)
}
}