snakesystemtest.java

来自「一个贪吃蛇游戏」· Java 代码 · 共 77 行

JAVA
77
字号
/**
 * @(#)SnakeSystemTest.java
 * @Unit tests for SnakeSystem class.
 *
 * @Link Scholes
 * @version 1.00 2008/7/24
 */

package Test;

import junit.framework.*;
import System.*;

public class SnakeSystemTest extends TestCase
{
	//The SnakeSystem instance for test.
	private SnakeSystem system = null;
	
	//Set up the testing environment.
	protected void setUp()
	{
		system = new SnakeSystem();
	}
	
	//Returns the test suite of this class.
	public static Test suite()
	{
		return new TestSuite(SnakeSystem.class);
	}
	
	//Accuracy test for contructor SnakeSystem().
	public void testSnakeSystem()
	{
		assertNotNull("The instance should not be null.",system);
	}
	
	//Accuracy test for getDirection().
	public void testGetDirection()
	{
		assertEquals("The direction should be correct",1,system.getDirection());
	}
	
	//Accuracy test for getLife().
	public void testGetLife()
	{
		assertEquals("The life should be correct",3,system.getLife());
	}
	
	//Accuracy test for getPosition().
	public void testGetPosition()
	{
		assertEquals("The position should be correct",0,system.getPosition());
	}
	
	//Accuracy test for neos().
	public void testNeos()
	{
		system.neos();
		assertEquals("The life should be correct",4,system.getLife());
	}
	
	//Accuracy test for reborn().
	public void testReborn()
	{
		system.reborn();
		assertEquals("The life should be correct",2,system.getLife());
		assertEquals("The position should be correct",0,system.getPosition());
	}
	
	//Accuracy test for newStage().
	public void testNewStage()
	{
		system.newStage(4,404);
		assertEquals("The direction should be correct",4,system.getDirection());
		assertEquals("The position should be correct",404,system.getPosition());
	}
}	//end class SnakeSystemTest

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?