# HG changeset patch # User 0-range@bazon.ru # Date 1308491639 -14400 # Node ID 89f13f20930265ec5d59939a28d16a1aedb30aff # Parent 50ef27b8b7dc5a1b9ad2bc817830f153c8719d59 changes diff -r 50ef27b8b7dc -r 89f13f209302 src/test/java/ru/alphatech/icfpc/cards/tests/TestDbl.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/test/java/ru/alphatech/icfpc/cards/tests/TestDbl.java Sun Jun 19 17:53:59 2011 +0400 @@ -0,0 +1,55 @@ +package ru.alphatech.icfpc.cards.tests; + +import junit.framework.Assert; + +import org.junit.Test; + +import ru.alphatech.icfpc.cards.Dbl; +import ru.alphatech.icfpc.cards.I; +import ru.alphatech.icfpc.game.ICFPCException; +import ru.alphatech.icfpc.game.IValue; +import ru.alphatech.icfpc.game.Player; +import ru.alphatech.icfpc.game.Value; + +public class TestDbl extends Assert +{ + @Test + public void testEqualValue() + { + Player opponent = new Player(); + Player proponent = new Player(); + assertEquals(65535, ((Value)new Dbl().returnValue(new Value(32768), proponent, opponent)).getValue()); + } + + public void testBiggestValue() + { + Player opponent = new Player(); + Player proponent = new Player(); + + assertEquals(65535, ((Value)new Dbl().returnValue(new Value(35000), proponent, opponent)).getValue()); + } + + public void testValue() + { + Player opponent = new Player(); + Player proponent = new Player(); + + assertEquals(22, ((Value)new Dbl().returnValue(new Value(11), proponent, opponent)).getValue()); + } + + public void testErrorValue() + { + Player opponent = new Player(); + Player proponent = new Player(); + IValue i = new I(); + try + { + new Dbl().returnValue(i, proponent, opponent); + assertFalse(true); + } + catch (ICFPCException e) + { + assertTrue(true); + } + } +} diff -r 50ef27b8b7dc -r 89f13f209302 src/test/java/ru/alphatech/icfpc/cards/tests/TestGet.java --- a/src/test/java/ru/alphatech/icfpc/cards/tests/TestGet.java Sun Jun 19 15:11:22 2011 +0400 +++ b/src/test/java/ru/alphatech/icfpc/cards/tests/TestGet.java Sun Jun 19 17:53:59 2011 +0400 @@ -1,19 +1,89 @@ package ru.alphatech.icfpc.cards.tests; -import static org.junit.Assert.*; +import junit.framework.Assert; import org.junit.Test; +import ru.alphatech.icfpc.cards.Get; +import ru.alphatech.icfpc.cards.I; +import ru.alphatech.icfpc.game.ICFPCException; +import ru.alphatech.icfpc.game.IValue; +import ru.alphatech.icfpc.game.Player; +import ru.alphatech.icfpc.game.Value; + /** - * @author indvdum + * @author indvdum (idea) + * @author 0-range (implementation) * 18.06.2011 19:42:44 * */ -public class TestGet { +public class TestGet extends Assert +{ + @Test + public final void testReturnValue() + { + Player opponent = new Player(); + Player proponent = new Player(); + + IValue i = new Value(0); + IValue value = new Value(99); + + proponent.getSlot(((Value)i).getValue()).putValue(value); + assertEquals(value, new Get().returnValue(i, proponent, opponent)); + } @Test - public final void testReturnValue() { - assertEquals("test", "test"); + public final void testNotSlotNumber() + { + Player opponent = new Player(); + Player proponent = new Player(); + + try + { + IValue i = new I(); + new Get().returnValue(i, proponent, opponent); + assertTrue(false); + } + catch (ICFPCException e) + { + assertTrue(true); + } } + @Test + public final void testInvalidSlotNumber() + { + Player opponent = new Player(); + Player proponent = new Player(); + + try + { + IValue i = new Value(999); + new Get().returnValue(i, proponent, opponent); + assertTrue(false); + } + catch (ICFPCException e) + { + assertTrue(true); + } + } + + @Test + public final void testIfSlotDead() + { + Player opponent = new Player(); + Player proponent = new Player(); + + try + { + IValue i = new Value(0); + proponent.getSlot(((Value)i).getValue()).setVitality(0); + new Get().returnValue(i, proponent, opponent); + assertTrue(false); + } + catch (ICFPCException e) + { + assertTrue(true); + } + } } diff -r 50ef27b8b7dc -r 89f13f209302 src/test/java/ru/alphatech/icfpc/cards/tests/TestPut.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/test/java/ru/alphatech/icfpc/cards/tests/TestPut.java Sun Jun 19 17:53:59 2011 +0400 @@ -0,0 +1,25 @@ +package ru.alphatech.icfpc.cards.tests; + +import junit.framework.Assert; + +import org.junit.Test; + +import ru.alphatech.icfpc.cards.I; +import ru.alphatech.icfpc.cards.Put; +import ru.alphatech.icfpc.game.IValue; +import ru.alphatech.icfpc.game.Player; +import ru.alphatech.icfpc.game.Value; + +public class TestPut extends Assert +{ + @Test + public final void testReturnValue() + { + Player opponent = new Player(); + Player proponent = new Player(); + + IValue i = new Value(0); + + assertEquals(new I().getClass(), new Put().returnValue(i, proponent, opponent).getClass()); + } +} diff -r 50ef27b8b7dc -r 89f13f209302 src/test/java/ru/alphatech/icfpc/cards/tests/TestSucc.java --- a/src/test/java/ru/alphatech/icfpc/cards/tests/TestSucc.java Sun Jun 19 15:11:22 2011 +0400 +++ b/src/test/java/ru/alphatech/icfpc/cards/tests/TestSucc.java Sun Jun 19 17:53:59 2011 +0400 @@ -14,15 +14,39 @@ public class TestSucc extends TestCase { @Test + public void testEqualValue() + { + Player opponent = new Player(); + Player proponent = new Player(); + + assertEquals(65535, ((Value)new Succ().returnValue(new Value(65535), proponent, opponent)).getValue()); + } + + @Test + public void testBiggestValue() + { + Player opponent = new Player(); + Player proponent = new Player(); + + assertEquals(65535, ((Value)new Succ().returnValue(new Value(65536), proponent, opponent)).getValue()); + } + + @Test public void testValue() { Player opponent = new Player(); Player proponent = new Player(); - IValue x = new Value(10); + + assertEquals(11, ((Value)new Succ().returnValue(new Value(10), proponent, opponent)).getValue()); + } + + @Test + public void testErrorValue() + { + Player opponent = new Player(); + Player proponent = new Player(); IValue i = new I(); - assertEquals(65535, ((Value)new Succ().returnValue(new Value(65535), proponent, opponent)).getValue()); - assertEquals(65535, ((Value)new Succ().returnValue(new Value(65536), proponent, opponent)).getValue()); - assertEquals(11, ((Value)new Succ().returnValue(new Value(10), proponent, opponent)).getValue()); + try { new Succ().returnValue(i, proponent, opponent);