Test of getPlace method, of class Layer.
()
| 524 | * Test of getPlace method, of class Layer. |
| 525 | */ |
| 526 | @Test |
| 527 | public void testGet() { |
| 528 | System.out.println("get"); |
| 529 | |
| 530 | Layer instance = new Layer(world); |
| 531 | |
| 532 | try { |
| 533 | int x = 0; |
| 534 | int y = 0; |
| 535 | Place element = new Place("MyPlace", x, y, instance); |
| 536 | instance.put(element); |
| 537 | assertEquals(element, instance.get(x, y)); |
| 538 | } catch (Layer.PlaceNotInsertedException ex) { |
| 539 | Logger.getLogger(LayerTest.class.getName()).log(Level.SEVERE, null, ex); |
| 540 | fail(ex.getMessage()); |
| 541 | } |
| 542 | |
| 543 | try { |
| 544 | int x = -5; |
| 545 | int y = -2; |
| 546 | Place element = new Place("MyPlace", x, y, instance); |
| 547 | instance.put(element); |
| 548 | assertEquals(element, instance.get(x, y)); |
| 549 | } catch (Layer.PlaceNotInsertedException ex) { |
| 550 | Logger.getLogger(LayerTest.class.getName()).log(Level.SEVERE, null, ex); |
| 551 | fail(ex.getMessage()); |
| 552 | } |
| 553 | |
| 554 | try { |
| 555 | int x = 3; |
| 556 | int y = 9; |
| 557 | Place element = new Place("MyPlace", x, y, instance); |
| 558 | instance.put(element); |
| 559 | assertEquals(element, instance.get(x, y)); |
| 560 | } catch (Layer.PlaceNotInsertedException ex) { |
| 561 | Logger.getLogger(LayerTest.class.getName()).log(Level.SEVERE, null, ex); |
| 562 | fail(ex.getMessage()); |
| 563 | } |
| 564 | |
| 565 | // get unoccupied position |
| 566 | int x = 100; |
| 567 | int y = 0; |
| 568 | assertNull(instance.get(x, y)); |
| 569 | } |
| 570 | |
| 571 | /** |
| 572 | * Test of getNeighbors method, of class Layer. |