v2 / vlib / v / tests / builtin_arrays / fixed_array_to_string_test.v
41 lines · 41 sloc · 744 bytes · 6488041a749df9762348d019c4223908c476f2e2
Raw
1fn test_fixed_array_to_string() {
2 mut a1 := [3]string{}
3 a1[0] = '1'
4 a1[1] = '2'
5 a1[2] = '3'
6 assert '${a1}' == "['1', '2', '3']"
7 mut a2 := [2]string{}
8 a2[0] = 'a'
9 a2[1] = 'b'
10 assert '${a2}' == "['a', 'b']"
11 mut c1 := [3]int{}
12 c1[0] = 1
13 c1[1] = 2
14 c1[2] = 3
15 assert '${c1}' == '[1, 2, 3]'
16 mut c2 := [3]i16{}
17 c2[0] = 1
18 c2[1] = 2
19 c2[2] = 3
20 assert '${c2}' == '[1, 2, 3]'
21 mut c3 := [3]i64{}
22 c3[0] = 1
23 c3[1] = 2
24 c3[2] = 3
25 assert '${c3}' == '[1, 2, 3]'
26 mut c4 := [3]u64{}
27 c4[0] = 1
28 c4[1] = 2
29 c4[2] = 3
30 assert '${c4}' == '[1, 2, 3]'
31 mut d1 := [3]f64{}
32 d1[0] = 1.1
33 d1[1] = 2.2
34 d1[2] = 3.3
35 assert '${d1}' == '[1.1, 2.2, 3.3]'
36 mut d2 := [3]f32{}
37 d2[0] = 1.1
38 d2[1] = 2.2
39 d2[2] = 3.3
40 assert '${d2}' == '[1.1, 2.2, 3.3]'
41}
42