Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

New test case addElementsDuringLoop()

Shows how to solve a problem mentioned in
http://stackoverflow.com/questions/6460320.
  • Loading branch information...
commit ac3ab522aa962508ae1e28f3228740ec735293ff 1 parent d09b6de
@kriegaex authored
View
27 UpdateableTreeSet/src/de/scrum_master/util/test/UpdateableTreeSetTest.java
@@ -185,6 +185,33 @@ public void bulkUpdate() {
}
@Test
+ public void addElementsDuringLoop() {
+ for (MedalCount medalCount : medalRanking) {
+ medalRanking.markForUpdate(
+ new MedalCount(
+ medalCount.country + "X",
+ medalCount.gold + 1,
+ medalCount.silver + 2,
+ medalCount.bronze + 3
+ )
+ );
+ }
+
+ // Perform bulk update
+ medalRanking.updateMarked();
+
+ // Number of elements should have doubled to 6 now
+ assertEquals(6, medalRanking.size());
+
+ // Check if some of the changed properties are as expected
+ assertEquals("USAX", medalRanking.first().country);
+ assertEquals(10, medalRanking.first().bronze);
+
+ // Check overall sort order
+ assertTrue(isSortOrderOk(medalRanking));
+ }
+
+ @Test
public void noValueBulkUpdate() {
// Verify that no-op update does not do any damage
medalRanking.markForUpdate(medalRanking.first());
Please sign in to comment.
Something went wrong with that request. Please try again.