Skip to content

Commit fb52491

Browse files
committed
Fix String capacity growth tests for watchOS
watchOS devices can have different allocation characteristics from other devices. This modifies the string capacity growth tests to be more flexible about measuring the growth in capacity, specifically when more is allocated than requested.
1 parent 630a7fc commit fb52491

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)