v2 / vlib / v / tests / alias_cast_to_fixed_array_test.v
24 lines · 20 sloc · 343 bytes · 066f825dea7b10c4588a17da727d9af39c3c5721
Raw
1type Bytes = [3]u8
2type Strs = [3]string
3
4fn test_none() {
5 b := ?Bytes(none)
6 println(b)
7 assert b == none
8
9 c := ?Strs(none)
10 println(c)
11 assert c == none
12}
13
14fn test_non_none() {
15 b := ?Bytes([u8(1), 2, 3]!)
16 println(b)
17 assert b != none
18 assert b?[2] == 3
19
20 c := ?Strs(['a', 'b', 'c']!)
21 println(c)
22 assert c != none
23 assert c?[2] == 'c'
24}
25