⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 snakesystemtest.java

📁 一个贪吃蛇游戏
💻 JAVA
字号:
/**
 * @(#)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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -