[libgee] Update the foreach tests
- From: Maciej Marcin Piechotka <mpiechotka src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgee] Update the foreach tests
- Date: Tue, 16 Jul 2013 15:47:01 +0000 (UTC)
commit 4ff3633121cce77ac87043c74d4113500af27f38
Author: Maciej Piechotka <uzytkownik2 gmail com>
Date: Tue Jul 16 00:47:15 2013 +0200
Update the foreach tests
tests/testcollection.vala | 41 ++++++++++++++++++++++++++++++++++++++---
1 files changed, 38 insertions(+), 3 deletions(-)
---
diff --git a/tests/testcollection.vala b/tests/testcollection.vala
index e80d9dd..e152d87 100644
--- a/tests/testcollection.vala
+++ b/tests/testcollection.vala
@@ -675,7 +675,8 @@ public abstract class CollectionTests : Gee.TestCase {
count = 0;
test_iterator = test_collection.iterator ();
- res = test_collection.iterator ().foreach ((x) => {
+ var iter = test_collection.iterator ();
+ res = iter.foreach ((x) => {
assert (test_iterator.next ());
assert (x == test_iterator.get ());
count++;
@@ -683,10 +684,13 @@ public abstract class CollectionTests : Gee.TestCase {
});
assert (count == data.length);
assert (res == true);
+ assert (iter.valid);
+ assert (iter.get () == test_iterator.get ());
+ assert (!iter.has_next ());
count = 1;
test_iterator = test_collection.iterator ();
- Iterator<string> iter = test_collection.iterator ();
+ iter = test_collection.iterator ();
assert (iter.next ());
assert (iter.next ());
assert (test_iterator.next ());
@@ -698,6 +702,9 @@ public abstract class CollectionTests : Gee.TestCase {
});
assert (count == data.length);
assert (res == true);
+ assert (iter.valid);
+ assert (iter.get () == test_iterator.get ());
+ assert (!iter.has_next ());
count = 1;
test_iterator = test_collection.iterator ();
@@ -714,6 +721,9 @@ public abstract class CollectionTests : Gee.TestCase {
});
assert (count == data.length);
assert (res == true);
+ assert (iter.valid);
+ assert (iter.get () == test_iterator.get ());
+ assert (!iter.has_next ());
// Check for break after 1-3 elements
for (int i = 0; i < 3; i++) {
@@ -729,13 +739,22 @@ public abstract class CollectionTests : Gee.TestCase {
count = 0;
test_iterator = test_collection.iterator ();
- res = test_collection.iterator ().foreach ((x) => {
+ iter = test_collection.iterator ();
+ res = iter.foreach ((x) => {
assert (test_iterator.next ());
assert (x == test_iterator.get ());
return count++ != i;
});
assert (count == i + 1);
assert (res == false);
+ assert (iter.valid);
+ assert (iter.get () == test_iterator.get ());
+ assert (iter.has_next ());
+ while (test_iterator.next ()) {
+ assert (iter.next ());
+ assert (iter.get () == test_iterator.get ());
+ }
+ assert (!iter.has_next ());
count = 1;
test_iterator = test_collection.iterator ();
@@ -750,6 +769,14 @@ public abstract class CollectionTests : Gee.TestCase {
});
assert (count == i + 2);
assert (res == false);
+ assert (iter.valid);
+ assert (iter.get () == test_iterator.get ());
+ assert (iter.has_next ());
+ while (test_iterator.next ()) {
+ assert (iter.next ());
+ assert (iter.get () == test_iterator.get ());
+ }
+ assert (!iter.has_next ());
count = 1;
test_iterator = test_collection.iterator ();
@@ -765,6 +792,14 @@ public abstract class CollectionTests : Gee.TestCase {
});
assert (count == i + 2);
assert (res == false);
+ assert (iter.valid);
+ assert (iter.get () == test_iterator.get ());
+ assert (iter.has_next ());
+ while (test_iterator.next ()) {
+ assert (iter.next ());
+ assert (iter.get () == test_iterator.get ());
+ }
+ assert (!iter.has_next ());
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]