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

📄 snaketest.java

📁 一个贪吃蛇游戏
💻 JAVA
字号:
/**
 * @(#)SnakeTest.java
 * @Unit tests for Snake class.
 *
 * @Link Scholes
 * @version 1.00 2008/7/24
 */

package Test;

import junit.framework.*;
import Data.*;

public class SnakeTest extends TestCase
{
	//The Snake instance for test.
	private Snake snake = null;
	
	//Set up the testing environment.
	protected void setUp()
	{
		snake = new Snake(0);
	}
	
	//Returns the test suite of this class.
	public static Test suite()
	{
		return new TestSuite(Snake.class);
	}
	
	//Accuracy test for contructor Snake().
	public void testSnake()
	{
		assertNotNull("The instance should not be null.",snake);
	}
	
	//Accuracy test for getLength().
	public void testGetLength()
	{
		assertEquals("The length should be correct",1,snake.getLength());
	}
	
	//Accuracy test for increase().
	public void testIncrease()
	{
		snake.increase();
		assertEquals("The length should be correct",2,snake.getLength());
	}
	
	//Accuracy test for decrease().
	public void testDecrease()
	{
		snake.increase();
		snake.decrease();
		assertEquals("The length should be correct",1,snake.getLength());
	}
}	//end class SnakeTest

⌨️ 快捷键说明

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