Changeset 3476 in josm for trunk/test/unit
- Timestamp:
- 2010-08-29T12:58:38+02:00 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/data/osm/QuadBucketsTest.java
r3166 r3476 4 4 import java.io.FileInputStream; 5 5 import java.util.ArrayList; 6 import java.util.Collection; 7 import java.util.Iterator; 6 8 import java.util.List; 7 9 10 import org.fest.reflect.core.Reflection; 11 import org.fest.reflect.reference.TypeRef; 8 12 import org.junit.Assert; 9 13 import org.junit.Test; … … 20 24 List<Way> allWays = new ArrayList<Way>(ds.getWays()); 21 25 List<Relation> allRelations = new ArrayList<Relation>(ds.getRelations()); 26 27 QuadBuckets<Node> nodes = Reflection.field("nodes").ofType(new TypeRef<QuadBuckets<Node>>() {}).in(ds).get(); 28 QuadBuckets<Way> ways = Reflection.field("ways").ofType(new TypeRef<QuadBuckets<Way>>() {}).in(ds).get(); 29 Collection<Relation> relations = Reflection.field("relations").ofType(new TypeRef<Collection<Relation>>() {}).in(ds).get(); 30 31 int expectedCount = allNodes.size(); 22 32 for (OsmPrimitive o: allNodes) { 23 33 ds.removePrimitive(o); 34 checkIterator(nodes, --expectedCount); 24 35 } 36 expectedCount = allWays.size(); 25 37 for (OsmPrimitive o: allWays) { 26 38 ds.removePrimitive(o); 39 checkIterator(ways, --expectedCount); 27 40 } 28 41 for (OsmPrimitive o: allRelations) { 29 42 ds.removePrimitive(o); 30 43 } 44 Assert.assertTrue(nodes.isEmpty()); 45 Assert.assertTrue(ways.isEmpty()); 46 Assert.assertTrue(relations.isEmpty()); 47 } 31 48 32 Assert.assertTrue(ds.getNodes().isEmpty()); 33 Assert.assertTrue(ds.getWays().isEmpty()); 34 Assert.assertTrue(ds.getRelations().isEmpty()); 49 private void checkIterator(Collection<? extends OsmPrimitive> col, int expectedCount) { 50 int count = 0; 51 Iterator<? extends OsmPrimitive> it = col.iterator(); 52 while (it.hasNext()) { 53 count++; 54 it.next(); 55 } 56 Assert.assertEquals(expectedCount, count); 35 57 } 36 58
Note:
See TracChangeset
for help on using the changeset viewer.