Changeset 10901 in josm for trunk/test/unit/org
- Timestamp:
- 2016-08-26T19:32:24+02:00 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/data/osm/QuadBucketsTest.java
r8857 r10901 5 5 import java.io.InputStream; 6 6 import java.util.ArrayList; 7 import java.util.Arrays; 7 8 import java.util.Collection; 8 9 import java.util.Iterator; … … 90 91 } 91 92 } 93 94 /** 95 * Test handling of objects with invalid bbox 96 * @throws Exception 97 */ 98 @Test 99 public void testSpecialBBox() throws Exception { 100 QuadBuckets<Node> qbNodes = new QuadBuckets<>(); 101 QuadBuckets<Way> qbWays = new QuadBuckets<>(); 102 Way w1 = new Way(1); 103 Way w2 = new Way(2); 104 Way w3 = new Way(3); 105 Node n1 = new Node(1); 106 Node n2 = new Node(2); n2.setCoor(new LatLon(10, 20)); 107 Node n3 = new Node(3); n2.setCoor(new LatLon(20, 30)); 108 w2.setNodes(Arrays.asList(n1)); 109 w3.setNodes(Arrays.asList(n1, n2, n3)); 110 111 qbNodes.add(n1); 112 qbNodes.add(n2); 113 Assert.assertEquals(2, qbNodes.size()); 114 Assert.assertTrue(qbNodes.contains(n1)); 115 Assert.assertTrue(qbNodes.contains(n2)); 116 Assert.assertFalse(qbNodes.contains(n3)); 117 qbNodes.remove(n1); 118 Assert.assertEquals(1, qbNodes.size()); 119 Assert.assertFalse(qbNodes.contains(n1)); 120 Assert.assertTrue(qbNodes.contains(n2)); 121 qbNodes.remove(n2); 122 Assert.assertEquals(0, qbNodes.size()); 123 Assert.assertFalse(qbNodes.contains(n1)); 124 Assert.assertFalse(qbNodes.contains(n2)); 125 126 qbNodes.addAll(Arrays.asList(n1, n2, n3)); 127 qbNodes.removeAll(Arrays.asList(n1, n3)); 128 Assert.assertEquals(1, qbNodes.size()); 129 Assert.assertTrue(qbNodes.contains(n2)); 130 131 qbWays.add(w1); 132 qbWays.add(w2); 133 qbWays.add(w3); 134 Assert.assertEquals(3, qbWays.size()); 135 Assert.assertTrue(qbWays.contains(w1)); 136 Assert.assertTrue(qbWays.contains(w2)); 137 Assert.assertTrue(qbWays.contains(w3)); 138 qbWays.remove(w1); 139 Assert.assertEquals(2, qbWays.size()); 140 Assert.assertFalse(qbWays.contains(w1)); 141 Assert.assertTrue(qbWays.contains(w2)); 142 Assert.assertTrue(qbWays.contains(w3)); 143 qbWays.remove(w2); 144 Assert.assertEquals(1, qbWays.size()); 145 Assert.assertFalse(qbWays.contains(w1)); 146 Assert.assertFalse(qbWays.contains(w2)); 147 Assert.assertTrue(qbWays.contains(w3)); 148 qbWays.remove(w3); 149 Assert.assertEquals(0, qbWays.size()); 150 Assert.assertFalse(qbWays.contains(w1)); 151 Assert.assertFalse(qbWays.contains(w2)); 152 Assert.assertFalse(qbWays.contains(w3)); 153 154 qbWays.clear(); 155 Assert.assertEquals(0, qbWays.size()); 156 List<Way> allWays = new ArrayList<>(Arrays.asList(w1, w2, w3)); 157 qbWays.addAll(allWays); 158 Assert.assertEquals(3, qbWays.size()); 159 int count = 0; 160 for (Way w : qbWays) { 161 Assert.assertTrue(allWays.contains(w)); 162 count++; 163 } 164 Assert.assertEquals(3, count); 165 // test remove with iterator 166 Iterator<Way> iter = qbWays.iterator(); 167 while (iter.hasNext()) { 168 iter.next(); 169 iter.remove(); 170 count--; 171 Assert.assertEquals(count, qbWays.size()); 172 } 173 Assert.assertEquals(0, qbWays.size()); 174 } 92 175 }
Note:
See TracChangeset
for help on using the changeset viewer.