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

Method testPut_3args

src/test/java/mudmap2/backend/LayerTest.java:377–447  ·  view source on GitHub ↗

Test of putPlace method, of class Layer.

()

Source from the content-addressed store, hash-verified

375 * Test of putPlace method, of class Layer.
376 */
377 @Test
378 public void testPut_3args(){
379 System.out.println("put");
380
381 Layer instance = new Layer(world);
382 Layer other = world.getNewLayer();
383
384 try {
385 int x = 0;
386 int y = 0;
387 Place element = new Place("MyPlace", x, y, instance);
388 instance.put(element, x, y);
389 assertEquals(element, instance.get(x, y));
390 } catch (Exception ex) {
391 Logger.getLogger(LayerTest.class.getName()).log(Level.SEVERE, null, ex);
392 fail(ex.getMessage());
393 }
394
395 try {
396 int x = -5;
397 int y = -2;
398 Place element = new Place("MyPlace", x, y, instance);
399 instance.put(element, x, y);
400 assertEquals(element, instance.get(x, y));
401 } catch (Exception ex) {
402 Logger.getLogger(LayerTest.class.getName()).log(Level.SEVERE, null, ex);
403 fail(ex.getMessage());
404 }
405
406 try {
407 int x = 3;
408 int y = 9;
409 Place element = new Place("MyPlace", x, y, instance);
410 instance.put(element, x, y);
411 assertEquals(element, instance.get(x, y));
412 } catch (Exception ex) {
413 Logger.getLogger(LayerTest.class.getName()).log(Level.SEVERE, null, ex);
414 fail(ex.getMessage());
415 }
416
417 // try to put a place to an occupied position
418 try {
419 int x = 0;
420 int y = 0;
421 Place element = new Place("MyPlace", x, y, instance);
422 instance.put(element, x, y);
423 fail();
424 } catch (Exception ex) {
425 // expected
426 }
427
428 // move place to a different layer
429 try {
430 // put on other layer
431 int x1 = 3;
432 int y1 = 7;
433 Place element = new Place("MyPlace", x1, y1, instance);
434 other.put(element, x1, y1);

Callers

nothing calls this directly

Calls 4

putMethod · 0.95
getMethod · 0.95
getNewLayerMethod · 0.80
getNameMethod · 0.45

Tested by

no test coverage detected