@@ -397,18 +397,18 @@ class TestData : TestDataSuper {
397
397
398
398
func testCopyBytes( ) {
399
399
let c = 10
400
- let underlyingBuffer = malloc ( c * strideof( UInt16) ) !
400
+ let underlyingBuffer = malloc ( c * strideof( UInt16 . self ) ) !
401
401
let buffer = UnsafeMutableBufferPointer < UInt16 > ( start: UnsafeMutablePointer < UInt16 > ( underlyingBuffer) , count: c)
402
402
403
403
buffer [ 0 ] = 0
404
404
buffer [ 1 ] = 0
405
405
406
- var data = Data ( capacity: c * strideof( UInt16) ) !
407
- data. resetBytes ( in: 0 ..< c * strideof( UInt16) )
406
+ var data = Data ( capacity: c * strideof( UInt16 . self ) ) !
407
+ data. resetBytes ( in: 0 ..< c * strideof( UInt16 . self ) )
408
408
data [ 0 ] = 0xFF
409
409
data [ 1 ] = 0xFF
410
410
let copiedCount = data. copyBytes ( to: buffer)
411
- expectEqual ( copiedCount, c * strideof( UInt16) )
411
+ expectEqual ( copiedCount, c * strideof( UInt16 . self ) )
412
412
413
413
expectEqual ( buffer [ 0 ] , 0xFFFF )
414
414
free ( underlyingBuffer)
@@ -419,7 +419,7 @@ class TestData : TestDataSuper {
419
419
var data = a. withUnsafeBufferPointer {
420
420
return Data ( buffer: $0)
421
421
}
422
- let expectedSize = strideof ( UInt8) * a. count
422
+ let expectedSize = strideof ( UInt8 . self ) * a. count
423
423
expectEqual ( expectedSize, data. count)
424
424
425
425
let underlyingBuffer = unsafeBitCast ( malloc ( expectedSize - 1 ) !, to: UnsafeMutablePointer< UInt8> . self )
@@ -443,7 +443,7 @@ class TestData : TestDataSuper {
443
443
var data = a. withUnsafeBufferPointer {
444
444
return Data ( buffer: $0)
445
445
}
446
- let expectedSize = strideof ( Int32) * a. count
446
+ let expectedSize = strideof ( Int32 . self ) * a. count
447
447
expectEqual ( expectedSize, data. count)
448
448
449
449
let underlyingBuffer = unsafeBitCast ( malloc ( expectedSize + 1 ) !, to: UnsafeMutablePointer< UInt8> . self )
@@ -606,14 +606,14 @@ class TestData : TestDataSuper {
606
606
return Data ( buffer: $0)
607
607
}
608
608
609
- var expectedSize = strideof ( Int32) * a. count
609
+ var expectedSize = strideof ( Int32 . self ) * a. count
610
610
expectEqual ( expectedSize, data. count)
611
611
612
612
[ false , true ] . withUnsafeBufferPointer {
613
613
data. append ( $0)
614
614
}
615
615
616
- expectedSize += strideof ( Bool) * 2
616
+ expectedSize += strideof ( Bool . self ) * 2
617
617
expectEqual ( expectedSize, data. count)
618
618
619
619
let underlyingBuffer = unsafeBitCast ( malloc ( expectedSize) !, to: UnsafeMutablePointer< UInt8> . self )
@@ -716,48 +716,48 @@ class TestData : TestDataSuper {
716
716
return Data ( buffer: $0)
717
717
}
718
718
719
- expectEqual ( data. count, strideof ( MyStruct) * 3 )
719
+ expectEqual ( data. count, strideof ( MyStruct . self ) * 3 )
720
720
721
721
722
722
// append
723
723
stuff. withUnsafeBufferPointer {
724
724
data. append ( $0)
725
725
}
726
726
727
- expectEqual ( data. count, strideof ( MyStruct) * 6 )
727
+ expectEqual ( data. count, strideof ( MyStruct . self ) * 6 )
728
728
729
729
// copyBytes
730
730
do {
731
731
// equal size
732
- let underlyingBuffer = malloc ( 6 * strideof( MyStruct) ) !
732
+ let underlyingBuffer = malloc ( 6 * strideof( MyStruct . self ) ) !
733
733
defer { free ( underlyingBuffer) }
734
734
735
735
let buffer = UnsafeMutableBufferPointer < MyStruct > ( start: UnsafeMutablePointer < MyStruct > ( underlyingBuffer) , count: 6 )
736
736
737
737
let byteCount = data. copyBytes ( to: buffer)
738
- expectEqual ( 6 * strideof( MyStruct) , byteCount)
738
+ expectEqual ( 6 * strideof( MyStruct . self ) , byteCount)
739
739
}
740
740
741
741
do {
742
742
// undersized
743
- let underlyingBuffer = malloc ( 3 * strideof( MyStruct) ) !
743
+ let underlyingBuffer = malloc ( 3 * strideof( MyStruct . self ) ) !
744
744
defer { free ( underlyingBuffer) }
745
745
746
746
let buffer = UnsafeMutableBufferPointer < MyStruct > ( start: UnsafeMutablePointer < MyStruct > ( underlyingBuffer) , count: 3 )
747
747
748
748
let byteCount = data. copyBytes ( to: buffer)
749
- expectEqual ( 3 * strideof( MyStruct) , byteCount)
749
+ expectEqual ( 3 * strideof( MyStruct . self ) , byteCount)
750
750
}
751
751
752
752
do {
753
753
// oversized
754
- let underlyingBuffer = malloc ( 12 * strideof( MyStruct) ) !
754
+ let underlyingBuffer = malloc ( 12 * strideof( MyStruct . self ) ) !
755
755
defer { free ( underlyingBuffer) }
756
756
757
757
let buffer = UnsafeMutableBufferPointer < MyStruct > ( start: UnsafeMutablePointer < MyStruct > ( underlyingBuffer) , count: 6 )
758
758
759
759
let byteCount = data. copyBytes ( to: buffer)
760
- expectEqual ( 6 * strideof( MyStruct) , byteCount)
760
+ expectEqual ( 6 * strideof( MyStruct . self ) , byteCount)
761
761
}
762
762
}
763
763
0 commit comments