[libgee] Add filter tests
- From: Maciej Marcin Piechotka <mpiechotka src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgee] Add filter tests
- Date: Wed, 17 Aug 2011 20:45:51 +0000 (UTC)
commit 663d02a6f84048290b94569ab08bf97d15ce4ce1
Author: Maciej Piechotka <uzytkownik2 gmail com>
Date: Wed Aug 17 21:42:56 2011 +0100
Add filter tests
tests/testcollection.vala | 37 +++++++++++++++++++++++++++++++++++++
1 files changed, 37 insertions(+), 0 deletions(-)
---
diff --git a/tests/testcollection.vala b/tests/testcollection.vala
index 246b94b..fa5304d 100644
--- a/tests/testcollection.vala
+++ b/tests/testcollection.vala
@@ -49,6 +49,7 @@ public abstract class CollectionTests : Gee.TestCase {
add_test ("[Collection] foreach", test_foreach);
add_test ("[Collection] map", test_map);
add_test ("[Collection] scan", test_scan);
+ add_test ("[Collection] filter", test_filter);
}
protected Collection<string> test_collection;
@@ -863,5 +864,41 @@ public abstract class CollectionTests : Gee.TestCase {
assert (two);
assert (three);
}
+
+ public void test_filter () {
+ assert (test_collection.add ("one"));
+ assert (test_collection.add ("two"));
+ assert (test_collection.add ("three"));
+
+ bool one = false;
+ bool two = false;
+ bool three = false;
+
+ var iter = test_collection.iterator().filter ((str) => {
+ if (str == "one") {
+ assert (!one);
+ one = true;
+ } else if (str == "two") {
+ assert (!two);
+ two = true;
+ } else if (str == "three") {
+ assert (!three);
+ three = true;
+ } else {
+ assert_not_reached ();
+ }
+ return str != "two";
+ });
+
+ assert (!iter.valid);
+
+ int j = 0;
+ while (iter.next ())
+ j++;
+ assert (j == 2);
+ assert (one);
+ assert (two);
+ assert (three);
+ }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]