1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
|
void test_glist () {
var list = new GLib.List<string> ();
assert (list.is_empty ());
list.prepend ("foo");
list.prepend ("bar");
assert (!list.is_empty ());
assert (list.nth_data (1) == "foo");
list = null;
var list2 = new GLib.List<unowned string> ();
list2.prepend ("foo");
list2.prepend ("bar");
assert (list2.nth_data (1) == "foo");
list2 = null;
}
void test_gslist () {
var list = new GLib.SList<string> ();
assert (list.is_empty ());
list.prepend ("foo");
list.prepend ("bar");
assert (!list.is_empty ());
assert (list.nth_data (1) == "foo");
list = null;
var list2 = new GLib.SList<unowned string> ();
list2.prepend ("foo");
list2.prepend ("bar");
assert (list2.nth_data (1) == "foo");
list2 = null;
}
void test_gqueue () {
var queue = new GLib.Queue<string> ();
assert (queue.is_empty ());
queue.push_head ("foo");
queue.push_head ("bar");
assert (!queue.is_empty ());
assert (queue.peek_nth (1) == "foo");
queue = null;
var queue2 = new GLib.Queue<unowned string> ();
queue2.push_head ("foo");
queue2.push_head ("bar");
assert (queue2.peek_nth (1) == "foo");
queue2 = null;
}
void test_gnode () {
var nodes = new GLib.Node<string> ();
nodes.append_data ("foo");
nodes.append_data ("bar");
assert (nodes.nth_child (1).data == "bar");
nodes = null;
var nodes2 = new GLib.Node<unowned string> ();
nodes2.append_data ("foo");
nodes2.append_data ("bar");
assert (nodes2.nth_child (1).data == "bar");
nodes2 = null;
}
void main () {
test_glist ();
test_gslist ();
test_gqueue ();
test_gnode ();
}
|