             return Data(buffer: $0)
         }
         
-        expectEqual(data.count, strideof(MyStruct.self) * 3)
+        expectEqual(data.count, MemoryLayout<MyStruct>.stride * 3)
         
         
         // append

            data.append($0)
        }
        
        expectEqual(data.count, strideof(MyStruct.self) * 6)

        // copyBytes
        do {
            // equal size
            let underlyingBuffer = malloc(6 * strideof(MyStruct.self))!
            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)
        }
        
        do {
            // undersized
            let underlyingBuffer = malloc(3 * strideof(MyStruct.self))!
            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)
        }
        
        do {
            // oversized
            let underlyingBuffer = malloc(12 * strideof(MyStruct.self))!
            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)
        }
    }
    

    
    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)
