MCPcopy Create free account
hub / github.com/Neop/mudmap2 / testBreadthSearch

Method testBreadthSearch

src/test/java/mudmap2/backend/WorldTest.java:842–919  ·  view source on GitHub ↗

Test of breadthSearch method, of class World.

()

Source from the content-addressed store, hash-verified

840 * Test of breadthSearch method, of class World.
841 */
842 @Test
843 public void testBreadthSearch() {
844 try {
845 System.out.println("breadthSearch");
846
847 World instance = new World();
848 Layer layer1 = instance.getNewLayer();
849 Layer layer2 = instance.getNewLayer();
850
851 // create places
852 Place place11 = new Place("", 0, 0, layer1);
853 Place place12 = new Place("", 1, 0, layer1);
854 Place place13 = new Place("", 2, 1, layer1);
855 Place place14 = new Place("", 5, 1, layer1);
856 // inaccessible place
857 Place place15 = new Place("", 5, 4, layer1);
858
859 layer1.put(place11);
860 layer1.put(place12);
861 layer1.put(place13);
862 layer1.put(place14);
863 layer1.put(place15);
864
865 // create connections
866 place11.connectPath(new Path(place11, "n", place12, "s"));
867 place12.connectPath(new Path(place12, "e", place13, "w"));
868 place13.connectPath(new Path(place13, "u", place14, "d"));
869 place14.connectPath(new Path(place14, "u", place11, "d"));
870
871 // first test 11 -> 11
872 Place result1 = instance.breadthSearch(place11, place11);
873 assertEquals(place11, result1);
874
875 BreadthSearch.BreadthSearchData breadthSearchData1 = result1.getBreadthSearchData();
876 assertNotNull(breadthSearchData1);
877 assertNull(breadthSearchData1.predecessor);
878
879 // second test 11 -> 12
880 Place result2 = instance.breadthSearch(place11, place12);
881 assertEquals(place12, result2);
882
883 BreadthSearch.BreadthSearchData breadthSearchData2 = result2.getBreadthSearchData();
884 assertNotNull(breadthSearchData2);
885 assertEquals(place11, breadthSearchData2.predecessor);
886 assertNull(breadthSearchData2.predecessor.breadthSearchData.predecessor);
887
888 // second test 11 -> 13
889 Place result3 = instance.breadthSearch(place11, place13);
890 assertEquals(place13, result3);
891
892 BreadthSearch.BreadthSearchData breadthSearchData3 = result3.getBreadthSearchData();
893 assertNotNull(breadthSearchData3);
894
895 assertTrue(place12 == breadthSearchData3.predecessor || place14 == breadthSearchData3.predecessor);
896 breadthSearchData3 = breadthSearchData3.predecessor.getBreadthSearchData();
897 assertNotNull(breadthSearchData3);
898
899 assertEquals(place11, breadthSearchData3.predecessor);

Callers

nothing calls this directly

Calls 6

getNewLayerMethod · 0.95
putMethod · 0.95
connectPathMethod · 0.95
breadthSearchMethod · 0.95
getBreadthSearchDataMethod · 0.95
getBreadthSearchDataMethod · 0.65

Tested by

no test coverage detected