             data.append($0)
         }
         
-        expectEqual(data.count, strideof(MyStruct.self) * 6)
+        expectEqual(data.count, MemoryLayout<MyStruct>.stride * 6)
 
         // copyBytes
         do {
             // equal size
-            let underlyingBuffer = malloc(6 * strideof(MyStruct.self))!
+            let underlyingBuffer = malloc(6 * MemoryLayout<MyStruct>.stride)!
             defer { free(underlyingBuffer) }
 
             let ptr = underlyingBuffer.bindMemory(to: MyStruct.self, capacity: 6)
             let buffer = UnsafeMutableBufferPointer<MyStruct>(start: ptr, count: 6)
             
             let byteCount = data.copyBytes(to: buffer)
-            expectEqual(6 * strideof(MyStruct.self), byteCount)
+            expectEqual(6 * MemoryLayout<MyStruct>.stride, byteCount)
         }
         
         do {
             // undersized
-            let underlyingBuffer = malloc(3 * strideof(MyStruct.self))!
+            let underlyingBuffer = malloc(3 * MemoryLayout<MyStruct>.stride)!
             defer { free(underlyingBuffer) }
 
             let ptr = underlyingBuffer.bindMemory(to: MyStruct.self, capacity: 3)
             let buffer = UnsafeMutableBufferPointer<MyStruct>(start: ptr, count: 3)
             
             let byteCount = data.copyBytes(to: buffer)
-            expectEqual(3 * strideof(MyStruct.self), byteCount)
+            expectEqual(3 * MemoryLayout<MyStruct>.stride, byteCount)
         }
         
         do {
             // oversized
-            let underlyingBuffer = malloc(12 * strideof(MyStruct.self))!
+            let underlyingBuffer = malloc(12 * MemoryLayout<MyStruct>.stride)!
             defer { free(underlyingBuffer) }
             
             let ptr = underlyingBuffer.bindMemory(to: MyStruct.self, capacity: 6)
             let buffer = UnsafeMutableBufferPointer<MyStruct>(start: ptr, count: 6)
             
             let byteCount = data.copyBytes(to: buffer)
-            expectEqual(6 * strideof(MyStruct.self), byteCount)
+            expectEqual(6 * MemoryLayout<MyStruct>.stride, byteCount)
         }
     }
     

            return Data(buffer: $0)
        }
        
        var expectedSize = strideof(Int32.self) * a.count
        expectEqual(expectedSize, data.count)
        
        [false, true].withUnsafeBufferPointer {
            data.append($0)
        }
        
        expectedSize += strideof(Bool.self) * 2
        expectEqual(expectedSize, data.count)
        
        let underlyingBuffer = unsafeBitCast(malloc(expectedSize)!, to: UnsafeMutablePointer<UInt8>.self)

    
    func testCopyBytes() {
        let c = 10
        let underlyingBuffer = malloc(c * MemoryLayout<UInt16>.stride)!
        let u16Ptr = underlyingBuffer.bindMemory(to: UInt16.self, capacity: c)
        let buffer = UnsafeMutableBufferPointer<UInt16>(start: u16Ptr, count: c)
        
        buffer[0] = 0
        buffer[1] = 0
        
        var data = Data(capacity: c * MemoryLayout<UInt16>.stride)
        data.resetBytes(in: 0..<c * MemoryLayout<UInt16>.stride)
        data[0] = 0xFF
        data[1] = 0xFF
        let copiedCount = data.copyBytes(to: buffer)
        expectEqual(copiedCount, c * MemoryLayout<UInt16>.stride)
        
        expectEqual(buffer[0], 0xFFFF)
        free(underlyingBuffer)
