mirror of
https://github.com/vlang/v.git
synced 2025-09-15 07:22:27 +03:00
vlib/arrays: fix copy
to not use memcpy for array, map, string (#13703)
This commit is contained in:
parent
de2fc87995
commit
4bea35b028
2 changed files with 31 additions and 1 deletions
|
@ -281,3 +281,15 @@ fn test_copy() {
|
|||
assert copy(mut b, [8, 9]) == 2
|
||||
assert b == [8, 9, 3, 7]
|
||||
}
|
||||
|
||||
fn test_can_copy_bits() {
|
||||
assert can_copy_bits<byte>()
|
||||
assert can_copy_bits<int>()
|
||||
assert can_copy_bits<voidptr>()
|
||||
assert can_copy_bits<&byte>()
|
||||
// autofree needs to intercept assign
|
||||
assert !can_copy_bits<string>()
|
||||
assert !can_copy_bits<[]int>()
|
||||
// map not copyable
|
||||
assert !can_copy_bits<map[string]int>()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue