()
| 193 | } |
| 194 | |
| 195 | public void testHostMoving() { |
| 196 | final int NROF = 15; |
| 197 | |
| 198 | setupMapData(null, "1,1", null); |
| 199 | DTNHost h1 = setupHost(); |
| 200 | Coord loc = h1.getLocation().clone(); |
| 201 | |
| 202 | for (int i=0; i<NROF; i++) { |
| 203 | h1.move(1); |
| 204 | // should always be 1 meter a way from the previous place |
| 205 | assertEquals(1.0, loc.distance(h1.getLocation())); |
| 206 | loc = h1.getLocation().clone(); |
| 207 | } |
| 208 | |
| 209 | h1 = setupHost(); |
| 210 | loc = h1.getLocation().clone(); |
| 211 | for (int i=0; i<NROF; i++ ) { |
| 212 | h1.move(2); |
| 213 | // should move 2 steps away from previous location |
| 214 | double dist = loc.distance(h1.getLocation()); |
| 215 | assertTrue(dist == 2 || dist == 0 || dist == Math.sqrt(2)); |
| 216 | loc = h1.getLocation().clone(); |
| 217 | } |
| 218 | |
| 219 | h1 = setupHost(); |
| 220 | loc = h1.getLocation().clone(); |
| 221 | for (int i=0; i<NROF; i++ ) { |
| 222 | h1.move(3); |
| 223 | // should move 3 steps away from previous location |
| 224 | double dist = loc.distance(h1.getLocation()); |
| 225 | assertTrue(dist == 3 || dist == 1 || dist == Math.sqrt(1+2*2) || |
| 226 | dist == Math.sqrt(2)); |
| 227 | loc = h1.getLocation().clone(); |
| 228 | } |
| 229 | } |
| 230 | |
| 231 | private DTNHost setupHost() { |
| 232 | TestUtils utils = new TestUtils(null, null, s); |
nothing calls this directly
no test coverage detected