v2 / vlib / v / tests / options / option_array_push_test.v
21 lines · 18 sloc · 358 bytes · 0e93a12bd938e6244cc57fac4e76176a37849d42
Raw
1pub struct Struct1 {
2pub mut:
3 strings ?[]string
4}
5
6fn test_main() {
7 mut s1 := Struct1{}
8 assert s1.strings == none
9 s1.strings = []
10 assert s1.strings? == []
11 s1.strings? << ['foo']
12 s1.strings? << ['bar']
13 dump(s1)
14 assert s1.strings? == ['foo', 'bar']
15
16 s1.strings = []
17 assert s1.strings? == []
18
19 s1.strings? << ['foo']
20 assert s1.strings? == ['foo']
21}
22