Skip to content

Commit 6d6f899

Browse files
authored
Merge pull request #97 from benlangmuir/rand-delete
[test] Fix rare failure in LineTable editing test
2 parents 2b695f0 + 116389b commit 6d6f899

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

Tests/SKSupportTests/SupportPerfTests.swift

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ final class SupportPerfTests: PerfTestCase {
4747
}
4848

4949
func testLineTableSingleCharEditPerf() {
50-
5150
let characters: [Character] = [
5251
"\t", "\n"
5352
] + (32...126).map { Character(UnicodeScalar($0)) }
@@ -72,9 +71,9 @@ final class SupportPerfTests: PerfTestCase {
7271
self.startMeasuring()
7372

7473
for _ in 1...iterations {
75-
let line = (0..<(t.count-1)).randomElement(using: &lcg)!
76-
let col = (0 ..< t[line].utf16.count).randomElement(using: &lcg)!
77-
let len = Bool.random() ? 1 : 0
74+
let line = (0 ..< (t.count-1)).randomElement(using: &lcg) ?? 0
75+
let col = (0 ..< t[line].utf16.count).randomElement(using: &lcg) ?? 0
76+
let len = t[line].isEmpty ? 0 : Bool.random() ? 1 : 0
7877
var newText = String(characters.randomElement(using: &lcg)!)
7978
if len == 1 && Bool.random(using: &lcg) {
8079
newText = "" // deletion

0 commit comments

Comments
 (0)