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 run: brew install swift-format
- name: Format - name: Format
run: make format run: make format
- uses: stefanzweifel/git-auto-commit-action@v4.1.6 - uses: stefanzweifel/git-auto-commit-action@v4
with: with:
commit_message: Run swift-format commit_message: Run swift-format
branch: 'master' branch: 'master'

View File

@@ -238,7 +238,8 @@ where Element: Identifiable, ID == Element.ID {
self.init([], id: \.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 replacingIds = self.ids[subrange]
let newIds = newElements.map { $0.id } let newIds = newElements.map { $0.id }
ids.replaceSubrange(subrange, with: newIds) ids.replaceSubrange(subrange, with: newIds)

View File

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