bzr branch
http://gegoxaren.bato24.eu/bzr/vqdr/trunk
|
50
by Gustav Hartvigsson
Added test for NamedVector |
1 |
using Utils; |
2 |
using GLib; |
|
3 |
||
4 |
void named_vector_test () { |
|
5 |
Test.add_func (UTIL_TEST_NAMED_VECTOR_PREFIX + "new", () => { |
|
6 |
var nv = new NamedVector<int> ("Hello,", 13, "world", 37, "!!", 69); |
|
7 |
}); |
|
8 |
||
9 |
Test.add_func (UTIL_TEST_NAMED_VECTOR_PREFIX + "sanity", () => { |
|
10 |
var nv = new NamedVector<int> ("A", 1, "B", 2, "C", 3); |
|
11 |
|
|
12 |
var tmp_name = nv.names[0]; |
|
13 |
if (tmp_name != "A") { |
|
14 |
Test.message ("Gotten value (%s) did not match the" + |
|
15 |
" expected value (A)", nv.names[0]); |
|
16 |
} |
|
17 |
||
18 |
tmp_name = nv.names[1]; |
|
19 |
if (tmp_name != "B") { |
|
20 |
Test.message ("Gotten value (%s) did not match the" + |
|
21 |
" expected value (B)", nv.names[0]); |
|
22 |
} |
|
23 |
|
|
24 |
tmp_name = nv.names[2]; |
|
25 |
if (tmp_name != "C") { |
|
26 |
Test.message ("Gotten value (%s) did not match the" + |
|
27 |
" expected value (C)", nv.names[0]); |
|
28 |
} |
|
29 |
||
30 |
}); |
|
31 |
||
32 |
Test.add_func (UTIL_TEST_NAMED_VECTOR_PREFIX + "foreach", () => { |
|
33 |
var nv = new NamedVector<int> ("A", 1, "B", 2, "C", 3); |
|
34 |
||
35 |
nv.foreach ((name, val) => { |
|
36 |
message ("%s has the value: %i \n", name, val); |
|
37 |
return true; |
|
38 |
}); |
|
39 |
}); |
|
40 |
}
|