File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -553,6 +553,32 @@ ${Suite}.test("${ArrayType}/init(unsafeUninitializedCapacity:...:)/throwing") {
553
553
expectEqual(0, InstanceCountedClass.instanceCounter)
554
554
}
555
555
556
+ ${Suite}.test("${ArrayType}/init(unsafeUninitializedCapacity:...:)/noCopy") {
557
+ var storageAddress: UnsafeMutablePointer<Int>?
558
+ var array = ${ArrayType}<Int>(unsafeUninitializedCapacity: 20) { buffer, _ in
559
+ storageAddress = buffer.baseAddress
560
+ }
561
+ array.withUnsafeMutableBufferPointer { buffer in
562
+ expectEqual(storageAddress, buffer.baseAddress)
563
+ }
564
+ }
565
+
566
+ ${Suite}.test("${ArrayType}/init(unsafeUninitializedCapacity:...:)/validCount") {
567
+ expectCrashLater()
568
+ let array = ${ArrayType}<Int>(unsafeUninitializedCapacity: 10) { buffer, c in
569
+ for i in 0..<10 { buffer[i] = i }
570
+ c = 20
571
+ }
572
+ }
573
+
574
+ ${Suite}.test("${ArrayType}/init(unsafeUninitializedCapacity:...:)/reassignBuffer") {
575
+ expectCrashLater()
576
+ let otherBuffer = UnsafeMutableBufferPointer<Int>.allocate(capacity: 1)
577
+ let array = ${ArrayType}<Int>(unsafeUninitializedCapacity: 10) { buffer, _ in
578
+ buffer = otherBuffer
579
+ }
580
+ }
581
+
556
582
%end
557
583
558
584
//===---
You can’t perform that action at this time.
0 commit comments