v2 / vlib / v / tests / builtin_maps / map_complex_array_test.v
21 lines · 20 sloc · 310 bytes · 1411c2710b03c53fa0de08d39c656d98721783f6
Raw
1struct Instr {
2mut:
3 a int
4 b int
5}
6
7fn test_map_complex_array() {
8 mut map1 := map[string][]&Instr{}
9 instr := &Instr{
10 a: 1
11 b: 2
12 }
13 arr := [instr]
14 map1['Hello'] = arr
15 unsafe {
16 map1['Hello'][0].a = 2
17 println(map1['Hello'][0].a)
18 assert map1['Hello'][0].a == 2
19 assert map1['Hello'][0].b == 2
20 }
21}
22