Skip to content

Commit b82fed4

Browse files
authored
Merge pull request #66278 from natecook1000/string_cow_test_fix
Fix String capacity growth tests for watchOS
2 parents 7e5ecfd + fb52491 commit b82fed4

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

validation-test/stdlib/String.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2380,7 +2380,8 @@ StringTests.test("String.CoW.reserveCapacity") {
23802380
let preGrowCapacity = str.capacity
23812381

23822382
// Growth shouldn't be linear
2383-
str.append(contentsOf: String(repeating: "z", count: 20))
2383+
let newElementCount = (preGrowCapacity - str.count) + 10
2384+
str.append(contentsOf: String(repeating: "z", count: newElementCount))
23842385
expectGE(str.capacity, preGrowCapacity * 2)
23852386

23862387
// Capacity can shrink when copying, but not below the count
@@ -2407,7 +2408,6 @@ StringTests.test("NSString.CoW.reserveCapacity") {
24072408
var copy2 = str2
24082409
copy2.append(contentsOf: String(repeating: "z", count: 10))
24092410
expectGE(copy2.capacity, 30)
2410-
expectLT(copy2.capacity, 40)
24112411
#endif
24122412
}
24132413

0 commit comments

Comments
 (0)