Skip to content

Commit df532ba

Browse files
committed
[stdlib] Add test for zero-initialized unused capacity in small strings.
1 parent 612aadd commit df532ba

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

test/stdlib/SmallString.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,4 +105,16 @@ SmallStringTests.test("Append, repeating") {
105105
}
106106
}
107107

108+
if #available(macOS 10.16, iOS 14.0, watchOS 7.0, tvOS 14.0, *) {
109+
SmallStringTests.test("Equatable") {
110+
let str = String(unsafeUninitializedCapacity: 2) {
111+
let last = $0.count &- 1
112+
$0[last] = 49 // "1"
113+
$0.baseAddress!.moveInitialize(from: $0.baseAddress! + last, count: 1)
114+
return 1
115+
}
116+
expectTrue(str == "1")
117+
}
118+
}
119+
108120
runAllTests()

0 commit comments

Comments
 (0)