Commit dd1449c6 authored by Simon McVittie's avatar Simon McVittie Committed by Maciej (Matthew) Piechotka
Browse files

Return true from HashSet.Iterator.foreach() if we fall off the end

This is documented to happen, and was implemented correctly in the other
collections, but not in HashSet.
parent b7aeceb8
......@@ -307,7 +307,7 @@ public class Gee.HashSet<G> : AbstractSet<G> {
_next = _set._nodes[_index];
}
}
return false;
return true;
}
}
}
......
......@@ -667,17 +667,25 @@ public abstract class CollectionTests : Gee.TestCase {
assert (test_collection.add ("three"));
int count = 0;
bool res;
test_collection.foreach ((x) => {count++; return true;});
res = test_collection.foreach ((x) => {count++; return true;});
assert (count == 3);
assert (res == true);
test_collection.iterator ().foreach ((x) => {count++; return true;});
res = test_collection.iterator ().foreach ((x) => {count++; return true;});
assert (count == 6);
assert (res == true);
Iterator<string> iter = test_collection.iterator ();
assert (iter.next ());
iter.foreach ((x) => {count++; return true;});
res = iter.foreach ((x) => {count++; return true;});
assert (count == 9);
assert (res == true);
res = test_collection.foreach ((x) => {count++; return false;});
assert (count == 10);
assert (res == false);
}
public void test_map () {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment