mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
map: another fix + test
This commit is contained in:
parent
26f5d34e64
commit
2096018b00
@ -57,6 +57,7 @@ fn (m mut map) insert(n mut mapnode, key string, val voidptr) {
|
||||
C.memcpy(n.val, val, m.element_size)
|
||||
if n.is_empty {
|
||||
m.size++
|
||||
n.is_empty = false
|
||||
}
|
||||
return
|
||||
}
|
||||
|
@ -189,3 +189,19 @@ fn test_ref() {
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
fn test_delete_size() {
|
||||
arr := ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
|
||||
mut m := map[string]int
|
||||
for _ in 0..10 {
|
||||
for i in 0..10 {
|
||||
m[arr[i]] = i
|
||||
}
|
||||
assert(m.size == 10)
|
||||
println(m.size)
|
||||
for i in 0..10 {
|
||||
m.delete(arr[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user