v2 / vlib / v / tests / structs / struct_field_array_index_test.v
17 lines · 13 sloc · 235 bytes · 6488041a749df9762348d019c4223908c476f2e2
Raw
1struct App {
2mut:
3 buffer []string
4}
5
6fn test_struct_field_array_index() {
7 mut app := &App{
8 buffer: []string{len: 2}
9 }
10
11 app.buffer[0] += 'hello'
12 app.buffer[1] += 'world'
13
14 println(app)
15
16 assert app.buffer == ['hello', 'world']
17}
18