|
2 | 2 |
|
3 | 3 | import bwem.BWEM; |
4 | 4 | import bwem.BWMap; |
| 5 | +import bwta.BWTA; |
| 6 | +import bwta.Chokepoint; |
| 7 | +import bwta.Region; |
5 | 8 | import org.junit.Test; |
6 | 9 |
|
7 | 10 | import java.io.IOException; |
| 11 | +import java.util.Collections; |
8 | 12 | import java.util.HashMap; |
| 13 | +import java.util.HashSet; |
| 14 | +import java.util.List; |
9 | 15 | import java.util.Map; |
10 | 16 |
|
11 | | -import static org.junit.Assert.assertEquals; |
| 17 | +import static org.junit.Assert.*; |
12 | 18 |
|
13 | 19 | public class BWEMTest { |
14 | 20 | static class BWEMMap{ |
@@ -66,13 +72,38 @@ public int hashCode() { |
66 | 72 | mapData.put("(4)Roadrunner.scx", new BWEMMap(26, 12, 35)); |
67 | 73 | } |
68 | 74 |
|
| 75 | + @Test |
| 76 | + public void chokePointsFromDifferentMapsAreDistinct() throws IOException { |
| 77 | + BWEM first = new BWEM(GameBuilder.createGame()); |
| 78 | + first.initialize(); |
| 79 | + BWEM second = new BWEM(GameBuilder.createGame()); |
| 80 | + second.initialize(); |
| 81 | + assertTrue(Collections.disjoint(first.getMap().getChokePoints(), second.getMap().getChokePoints())); |
| 82 | + } |
| 83 | + |
69 | 84 | @Test |
70 | 85 | public void checkSSCAITMaps() throws IOException { |
71 | 86 | for (String mapName : mapData.keySet()) { |
72 | | - Game game = GameBuilder.createGame(mapName); |
73 | | - BWEM bwem = new BWEM(game); |
74 | | - bwem.initialize(); |
75 | | - assertEquals(new BWEMMap(bwem.getMap()), mapData.get(mapName)); |
| 87 | + BWTA.readMap(GameBuilder.createGame(mapName)); |
| 88 | + BWTA.analyze(); |
| 89 | + BWMap map = BWTA.getBWEM().getMap(); |
| 90 | + assertEquals(new BWEMMap(map), mapData.get(mapName)); |
| 91 | + assertEquals(mapName, map.getChokePoints().size(), new HashSet<>(map.getChokePoints()).size()); |
| 92 | + |
| 93 | + List<Chokepoint> chokes = BWTA.getChokepoints(); |
| 94 | + assertEquals(mapName, map.getChokePoints().size(), chokes.size()); |
| 95 | + for (Chokepoint choke : chokes) { |
| 96 | + assertTrue(choke.getRegions().getLeft().getChokepoints().contains(choke)); |
| 97 | + assertTrue(choke.getRegions().getRight().getChokepoints().contains(choke)); |
| 98 | + } |
| 99 | + for (Region region : BWTA.getRegions()) { |
| 100 | + for (Chokepoint choke : region.getChokepoints()) { |
| 101 | + assertNotNull(mapName, choke); |
| 102 | + assertTrue(mapName, chokes.contains(choke)); |
| 103 | + assertTrue(choke.getRegions().getLeft().equals(region) |
| 104 | + || choke.getRegions().getRight().equals(region)); |
| 105 | + } |
| 106 | + } |
76 | 107 | } |
77 | 108 | } |
78 | 109 | } |
0 commit comments