Skip to content

Commit 7c01bdd

Browse files
authored
Adjust debug descriptions: remove final newline (#143)
Remove last terminator in customized `debugDescription`.
1 parent 534babf commit 7c01bdd

5 files changed

+10
-26
lines changed

Sources/DebugDescriptions.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ private func buildString<Target: TextOutputStream>(
3636
print("\(String(repeating: " ", count: indent))\(text)", to: &output)
3737
}
3838

39+
private func adjustLastTerminator(_ output: inout String) {
40+
if output.last == "\n" {
41+
output.removeLast()
42+
}
43+
}
44+
3945
// swiftlint:disable:next cyclomatic_complexity
4046
private func debugDescriptionBuilder<Target: TextOutputStream>(
4147
elements: [(Element, Int)],
@@ -168,6 +174,7 @@ func collectionDebugDescription(_ collection: CollectionViewModel) -> String {
168174
],
169175
to: &output
170176
)
177+
adjustLastTerminator(&output)
171178
return output
172179
}
173180

@@ -187,6 +194,7 @@ func sectionDebugDescription(_ section: SectionViewModel) -> String {
187194
],
188195
to: &output
189196
)
197+
adjustLastTerminator(&output)
190198
return output
191199
}
192200

@@ -201,6 +209,7 @@ func driverOptionsDebugDescription(_ options: CollectionViewDriverOptions) -> St
201209
],
202210
to: &output
203211
)
212+
adjustLastTerminator(&output)
204213
return output
205214
}
206215

@@ -225,5 +234,6 @@ func driverDebugDescription(
225234
],
226235
to: &output
227236
)
237+
adjustLastTerminator(&output)
228238
return output
229239
}

Tests/TestCollectionViewDriverOptions.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ final class TestCollectionViewDriverOptions: XCTestCase {
3232
diffOnBackgroundQueue: false
3333
reloadDataOnReplacingViewModel: false
3434
}
35-
3635
"""
3736
)
3837

@@ -47,7 +46,6 @@ final class TestCollectionViewDriverOptions: XCTestCase {
4746
diffOnBackgroundQueue: true
4847
reloadDataOnReplacingViewModel: true
4948
}
50-
5149
"""
5250
)
5351
}

Tests/TestDebugDescriptionCollection.swift

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ final class TestDebugDescriptionCollection: XCTestCase {
3333
registrations: none
3434
isEmpty: true
3535
}
36-
3736
"""
3837
)
3938
}
@@ -66,7 +65,6 @@ final class TestDebugDescriptionCollection: XCTestCase {
6665
- FakeTextCellViewModel (cell)
6766
isEmpty: false
6867
}
69-
7068
"""
7169
)
7270

@@ -96,7 +94,6 @@ final class TestDebugDescriptionCollection: XCTestCase {
9694
- FakeCellNibViewModel (cell)
9795
isEmpty: false
9896
}
99-
10097
"""
10198
)
10299
}
@@ -131,7 +128,6 @@ final class TestDebugDescriptionCollection: XCTestCase {
131128
- FakeTextCellViewModel (cell)
132129
isEmpty: false
133130
}
134-
135131
"""
136132
)
137133

@@ -163,7 +159,6 @@ final class TestDebugDescriptionCollection: XCTestCase {
163159
- FakeTextCellViewModel (cell)
164160
isEmpty: false
165161
}
166-
167162
"""
168163
)
169164

@@ -197,7 +192,6 @@ final class TestDebugDescriptionCollection: XCTestCase {
197192
- FakeTextCellViewModel (cell)
198193
isEmpty: false
199194
}
200-
201195
"""
202196
)
203197
}
@@ -239,7 +233,6 @@ final class TestDebugDescriptionCollection: XCTestCase {
239233
- FakeTextCellViewModel (cell)
240234
isEmpty: false
241235
}
242-
243236
"""
244237
)
245238
}
@@ -282,7 +275,6 @@ final class TestDebugDescriptionCollection: XCTestCase {
282275
- FakeTextCellViewModel (cell)
283276
isEmpty: false
284277
}
285-
286278
"""
287279
)
288280

@@ -322,7 +314,6 @@ final class TestDebugDescriptionCollection: XCTestCase {
322314
- FakeCellNibViewModel (cell)
323315
isEmpty: false
324316
}
325-
326317
"""
327318
)
328319

@@ -364,7 +355,6 @@ final class TestDebugDescriptionCollection: XCTestCase {
364355
- FakeTextCellViewModel (cell)
365356
isEmpty: false
366357
}
367-
368358
"""
369359
)
370360
}
@@ -409,7 +399,6 @@ final class TestDebugDescriptionCollection: XCTestCase {
409399
- FakeTextCellViewModel (cell)
410400
isEmpty: false
411401
}
412-
413402
"""
414403
)
415404

@@ -453,7 +442,6 @@ final class TestDebugDescriptionCollection: XCTestCase {
453442
- FakeTextCellViewModel (cell)
454443
isEmpty: false
455444
}
456-
457445
"""
458446
)
459447

@@ -505,7 +493,6 @@ final class TestDebugDescriptionCollection: XCTestCase {
505493
- FakeTextCellViewModel (cell)
506494
isEmpty: false
507495
}
508-
509496
"""
510497
)
511498
}

Tests/TestDebugDescriptionDriver.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ final class TestDebugDescriptionDriver: XCTestCase {
6868
flowLayoutDelegate: nil
6969
view: \(viewPattern)
7070
\\}
71-
7271
"""
7372

7473
XCTAssertTrue(driver.debugDescription.regexMatches(pattern: expected))
@@ -124,7 +123,6 @@ final class TestDebugDescriptionDriver: XCTestCase {
124123
flowLayoutDelegate: nil
125124
view: \(viewPattern)
126125
\\}
127-
128126
"""
129127

130128
XCTAssertTrue(driver.debugDescription.regexMatches(pattern: expected))
@@ -173,7 +171,6 @@ final class TestDebugDescriptionDriver: XCTestCase {
173171
flowLayoutDelegate: <ReactiveCollectionsKitTests\\.FakeFlowLayoutDelegate: \(Self.addressPattern)>
174172
view: \(viewPattern)
175173
\\}
176-
177174
"""
178175

179176
XCTAssertTrue(driver.debugDescription.regexMatches(pattern: expected))

Tests/TestDebugDescriptionSection.swift

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ final class TestDebugDescriptionSection: XCTestCase {
3535
registrations: none
3636
isEmpty: true
3737
}
38-
3938
"""
4039
)
4140
}
@@ -60,7 +59,6 @@ final class TestDebugDescriptionSection: XCTestCase {
6059
- FakeNumberCellViewModel (cell)
6160
isEmpty: false
6261
}
63-
6462
"""
6563
)
6664
}
@@ -88,7 +86,6 @@ final class TestDebugDescriptionSection: XCTestCase {
8886
- FakeTextCellViewModel (cell)
8987
isEmpty: false
9088
}
91-
9289
"""
9390
)
9491

@@ -113,7 +110,6 @@ final class TestDebugDescriptionSection: XCTestCase {
113110
- FakeCellNibViewModel (cell)
114111
isEmpty: false
115112
}
116-
117113
"""
118114
)
119115
}
@@ -143,7 +139,6 @@ final class TestDebugDescriptionSection: XCTestCase {
143139
- FakeTextCellViewModel (cell)
144140
isEmpty: false
145141
}
146-
147142
"""
148143
)
149144

@@ -170,7 +165,6 @@ final class TestDebugDescriptionSection: XCTestCase {
170165
- FakeTextCellViewModel (cell)
171166
isEmpty: false
172167
}
173-
174168
"""
175169
)
176170

@@ -199,7 +193,6 @@ final class TestDebugDescriptionSection: XCTestCase {
199193
- FakeTextCellViewModel (cell)
200194
isEmpty: false
201195
}
202-
203196
"""
204197
)
205198

@@ -233,7 +226,6 @@ final class TestDebugDescriptionSection: XCTestCase {
233226
- FakeTextCellViewModel (cell)
234227
isEmpty: false
235228
}
236-
237229
"""
238230
)
239231
}

0 commit comments

Comments
 (0)