map_test.v

pull/853/head
Alexander Medvednikov 2019-06-30 13:44:08 +02:00
parent c5a0b3734a
commit 388eb36ecb
1 changed files with 21 additions and 0 deletions

View File

@ -0,0 +1,21 @@
struct A {
m map_int
}
fn (a mut A) set(key string, val int) {
a.m[key] = val
}
fn test_map() {
mut m := map[string]int{}
m['hi'] = 80
assert m['hi'] == 80
mut a := A{
m: new_map(1, sizeof(int))
}
a.m['one'] = 1
a.set('two', 2)
assert a.m['one'] == 1
assert a.m['two'] == 2
}