* merge
authorindvdum
Sun, 19 Jun 2011 18:55:47 +0400
changeset 100875773ff406b
parent 99 60187fe9405d
parent 98 19dba9e387ce
child 101 4bb458c3548e
child 103 bb440d1c3ea4
* merge
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/test/java/ru/alphatech/icfpc/cards/tests/TestDbl.java	Sun Jun 19 18:55:47 2011 +0400
     1.3 @@ -0,0 +1,55 @@
     1.4 +package ru.alphatech.icfpc.cards.tests;
     1.5 +
     1.6 +import junit.framework.Assert;
     1.7 +
     1.8 +import org.junit.Test;
     1.9 +
    1.10 +import ru.alphatech.icfpc.cards.Dbl;
    1.11 +import ru.alphatech.icfpc.cards.I;
    1.12 +import ru.alphatech.icfpc.game.ICFPCException;
    1.13 +import ru.alphatech.icfpc.game.IValue;
    1.14 +import ru.alphatech.icfpc.game.Player;
    1.15 +import ru.alphatech.icfpc.game.Value;
    1.16 +
    1.17 +public class TestDbl extends Assert
    1.18 +{
    1.19 +	@Test
    1.20 +	public void testEqualValue()
    1.21 +	{
    1.22 +		Player opponent = new Player();
    1.23 +		Player proponent = new Player();
    1.24 +		assertEquals(65535, ((Value)new Dbl().returnValue(new Value(32768), proponent, opponent)).getValue());
    1.25 +	}
    1.26 +
    1.27 +	public void testBiggestValue()
    1.28 +	{
    1.29 +		Player opponent = new Player();
    1.30 +		Player proponent = new Player();
    1.31 +
    1.32 +		assertEquals(65535, ((Value)new Dbl().returnValue(new Value(35000), proponent, opponent)).getValue());
    1.33 +	}
    1.34 +
    1.35 +	public void testValue()
    1.36 +	{
    1.37 +		Player opponent = new Player();
    1.38 +		Player proponent = new Player();
    1.39 +
    1.40 +		assertEquals(22, ((Value)new Dbl().returnValue(new Value(11), proponent, opponent)).getValue());
    1.41 +	}
    1.42 +
    1.43 +	public void testErrorValue()
    1.44 +	{
    1.45 +		Player opponent = new Player();
    1.46 +		Player proponent = new Player();
    1.47 +		IValue i = new I();
    1.48 +		try
    1.49 +		{
    1.50 +			new Dbl().returnValue(i, proponent, opponent);
    1.51 +			assertFalse(true);
    1.52 +		}
    1.53 +		catch (ICFPCException e)
    1.54 +		{
    1.55 +			assertTrue(true);
    1.56 +		}
    1.57 +	}
    1.58 +}
     2.1 --- a/src/test/java/ru/alphatech/icfpc/cards/tests/TestGet.java	Sun Jun 19 18:55:26 2011 +0400
     2.2 +++ b/src/test/java/ru/alphatech/icfpc/cards/tests/TestGet.java	Sun Jun 19 18:55:47 2011 +0400
     2.3 @@ -1,19 +1,89 @@
     2.4  package ru.alphatech.icfpc.cards.tests;
     2.5  
     2.6 -import static org.junit.Assert.*;
     2.7 +import junit.framework.Assert;
     2.8  
     2.9  import org.junit.Test;
    2.10  
    2.11 +import ru.alphatech.icfpc.cards.Get;
    2.12 +import ru.alphatech.icfpc.cards.I;
    2.13 +import ru.alphatech.icfpc.game.ICFPCException;
    2.14 +import ru.alphatech.icfpc.game.IValue;
    2.15 +import ru.alphatech.icfpc.game.Player;
    2.16 +import ru.alphatech.icfpc.game.Value;
    2.17 +
    2.18  /**
    2.19 - * @author indvdum
    2.20 + * @author indvdum (idea)
    2.21 + * @author 0-range (implementation)
    2.22   * 18.06.2011 19:42:44
    2.23   *
    2.24   */
    2.25 -public class TestGet {
    2.26 +public class TestGet extends Assert
    2.27 +{
    2.28 +	@Test
    2.29 +	public final void testReturnValue()
    2.30 +	{
    2.31 +		Player opponent = new Player();
    2.32 +		Player proponent = new Player();
    2.33 +
    2.34 +		IValue i = new Value(0);
    2.35 +		IValue value = new Value(99);
    2.36 +
    2.37 +		proponent.getSlot(((Value)i).getValue()).putValue(value);
    2.38 +		assertEquals(value, new Get().returnValue(i, proponent, opponent));
    2.39 +	}
    2.40  
    2.41  	@Test
    2.42 -	public final void testReturnValue() {
    2.43 -		assertEquals("test", "test");
    2.44 +	public final void testNotSlotNumber()
    2.45 +	{
    2.46 +		Player opponent = new Player();
    2.47 +		Player proponent = new Player();
    2.48 +
    2.49 +		try
    2.50 +		{
    2.51 +			IValue i = new I();
    2.52 +			new Get().returnValue(i, proponent, opponent);
    2.53 +			assertTrue(false);
    2.54 +		}
    2.55 +		catch (ICFPCException e)
    2.56 +		{
    2.57 +			assertTrue(true);
    2.58 +		}
    2.59  	}
    2.60  
    2.61 +	@Test
    2.62 +	public final void testInvalidSlotNumber()
    2.63 +	{
    2.64 +		Player opponent = new Player();
    2.65 +		Player proponent = new Player();
    2.66 +
    2.67 +		try
    2.68 +		{
    2.69 +			IValue i = new Value(999);
    2.70 +			new Get().returnValue(i, proponent, opponent);
    2.71 +			assertTrue(false);
    2.72 +		}
    2.73 +		catch (ICFPCException e)
    2.74 +		{
    2.75 +			assertTrue(true);
    2.76 +		}
    2.77 +	}
    2.78 +
    2.79 +	@Test
    2.80 +	public final void testIfSlotDead()
    2.81 +	{
    2.82 +		Player opponent = new Player();
    2.83 +		Player proponent = new Player();
    2.84 +
    2.85 +		try
    2.86 +		{
    2.87 +			IValue i = new Value(0);
    2.88 +			proponent.getSlot(((Value)i).getValue()).setVitality(0);
    2.89 +			new Get().returnValue(i, proponent, opponent);
    2.90 +			assertTrue(false);
    2.91 +		}
    2.92 +		catch (ICFPCException e)
    2.93 +		{
    2.94 +			assertTrue(true);
    2.95 +		}
    2.96 +	}
    2.97  }
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/src/test/java/ru/alphatech/icfpc/cards/tests/TestPut.java	Sun Jun 19 18:55:47 2011 +0400
     3.3 @@ -0,0 +1,25 @@
     3.4 +package ru.alphatech.icfpc.cards.tests;
     3.5 +
     3.6 +import junit.framework.Assert;
     3.7 +
     3.8 +import org.junit.Test;
     3.9 +
    3.10 +import ru.alphatech.icfpc.cards.I;
    3.11 +import ru.alphatech.icfpc.cards.Put;
    3.12 +import ru.alphatech.icfpc.game.IValue;
    3.13 +import ru.alphatech.icfpc.game.Player;
    3.14 +import ru.alphatech.icfpc.game.Value;
    3.15 +
    3.16 +public class TestPut extends Assert
    3.17 +{
    3.18 +	@Test
    3.19 +	public final void testReturnValue()
    3.20 +	{
    3.21 +		Player opponent = new Player();
    3.22 +		Player proponent = new Player();
    3.23 +
    3.24 +		IValue i = new Value(0);
    3.25 +
    3.26 +		assertEquals(new I().getClass(), new Put().returnValue(i, proponent, opponent).getClass());
    3.27 +	}
    3.28 +}
     4.1 --- a/src/test/java/ru/alphatech/icfpc/cards/tests/TestSucc.java	Sun Jun 19 18:55:26 2011 +0400
     4.2 +++ b/src/test/java/ru/alphatech/icfpc/cards/tests/TestSucc.java	Sun Jun 19 18:55:47 2011 +0400
     4.3 @@ -14,15 +14,39 @@
     4.4  public class TestSucc extends TestCase
     4.5  {
     4.6  	@Test
     4.7 +	public void testEqualValue()
     4.8 +	{
     4.9 +		Player opponent = new Player();
    4.10 +		Player proponent = new Player();
    4.11 +		
    4.12 +		assertEquals(65535, ((Value)new Succ().returnValue(new Value(65535), proponent, opponent)).getValue());
    4.13 +	}
    4.14 +
    4.15 +	@Test
    4.16 +	public void testBiggestValue()
    4.17 +	{
    4.18 +		Player opponent = new Player();
    4.19 +		Player proponent = new Player();
    4.20 +
    4.21 +		assertEquals(65535, ((Value)new Succ().returnValue(new Value(65536), proponent, opponent)).getValue());
    4.22 +	}
    4.23 +
    4.24 +	@Test
    4.25  	public void testValue()
    4.26  	{
    4.27  		Player opponent = new Player();
    4.28  		Player proponent = new Player();
    4.29 -		IValue x = new Value(10);
    4.30 +
    4.31 +		assertEquals(11, ((Value)new Succ().returnValue(new Value(10), proponent, opponent)).getValue());
    4.32 +	}
    4.33 +
    4.34 +	@Test
    4.35 +	public void testErrorValue()
    4.36 +	{
    4.37 +		Player opponent = new Player();
    4.38 +		Player proponent = new Player();
    4.39  		IValue i = new I();
    4.40 -		assertEquals(65535, ((Value)new Succ().returnValue(new Value(65535), proponent, opponent)).getValue());
    4.41 -		assertEquals(65535, ((Value)new Succ().returnValue(new Value(65536), proponent, opponent)).getValue());
    4.42 -		assertEquals(11, ((Value)new Succ().returnValue(new Value(10), proponent, opponent)).getValue());
    4.43 +
    4.44  		try
    4.45  		{
    4.46  			new Succ().returnValue(i, proponent, opponent);