?? snakesystemtest.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 + -