[libgee] Add some tests for List.slice
- From: Didier 'Ptitjes' Villevalois <dvillevalois src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [libgee] Add some tests for List.slice
- Date: Mon, 14 Sep 2009 17:16:52 +0000 (UTC)
commit a9fca680640b0a622f85632f481c930bead6478f
Author: Didier 'Ptitjes <ptitjes free fr>
Date: Mon Sep 14 19:15:18 2009 +0200
Add some tests for List.slice
tests/testlist.vala | 42 ++++++++++++++++++++++++++++++++++++++++++
1 files changed, 42 insertions(+), 0 deletions(-)
---
diff --git a/tests/testlist.vala b/tests/testlist.vala
index 7cabdb1..cd4b0ad 100644
--- a/tests/testlist.vala
+++ b/tests/testlist.vala
@@ -41,6 +41,7 @@ public abstract class ListTests : CollectionTests {
add_test ("[List] first", test_first);
add_test ("[List] last", test_last);
add_test ("[List] insert_all", test_insert_all);
+ add_test ("[List] slice", test_slice);
}
public void test_iterator_is_ordered () {
@@ -547,4 +548,45 @@ public abstract class ListTests : CollectionTests {
assert (test_list.get (4) == "four");
assert (test_list.get (5) == "five");
}
+
+ public void test_slice () {
+ var test_list = test_collection as Gee.List<string>;
+
+ // Check the test list is not null
+ assert (test_list != null);
+ Gee.List<string> dummy;
+
+ // Check first for empty list
+ if (Test.trap_fork (0, TestTrapFlags.SILENCE_STDOUT |
+ TestTrapFlags.SILENCE_STDERR)) {
+ dummy = test_list.slice (1, 4);
+ return;
+ }
+ Test.trap_assert_failed ();
+
+ // Check for list with some items
+ assert (test_list.add ("zero"));
+ assert (test_list.add ("one"));
+ assert (test_list.add ("two"));
+ assert (test_list.add ("three"));
+ assert (test_list.add ("four"));
+ assert (test_list.add ("five"));
+ assert (test_list.size == 6);
+
+ dummy = test_list.slice (1, 4);
+ assert (dummy.size == 3);
+ assert (test_list.size == 6);
+
+ assert (dummy.get (0) == "one");
+ assert (dummy.get (1) == "two");
+ assert (dummy.get (2) == "three");
+
+ // Check for invalid indices
+ if (Test.trap_fork (0, TestTrapFlags.SILENCE_STDOUT |
+ TestTrapFlags.SILENCE_STDERR)) {
+ dummy = test_list.slice (0, 9);
+ return;
+ }
+ Test.trap_assert_failed ();
+ }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]