Skip to content
Snippets Groups Projects
Commit 8cc6311f authored by Sanjula's avatar Sanjula
Browse files

Update unit tests

parent f4f80ef1
No related branches found
No related tags found
No related merge requests found
......@@ -2,5 +2,6 @@
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="src" path=""/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
<classpathentry kind="output" path=""/>
</classpath>
......@@ -39,3 +39,7 @@
/MainMenuDisplay$2$1.class
/MainMenuDisplay$3$1.class
/ScoreDisplay$1.class
/testScore.class
/testTuple.class
/testThreadsController.class
/testGameDisplay.class
Off
Constant
Infinite
On
Increasing
Timed
On
import static org.junit.Assert.*;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
public class testScore {
Score one;
Score two;
Score three;
Score four;
@Before
public void setUp() throws Exception {
one = new Score("Obstacles | Increasing Speed | Timed | Autoreplay","3/15/2021",5);
two = new Score("Obstacles | Timed | Autoreplay","1/28/2021",10);
three = new Score("Obstacles | Increasing Speed","2/10/2021",1);
four = new Score("None","2/5/2021",30);
}
@After
public void tearDown() throws Exception {
one = null;
two = null;
three = null;
four = null;
}
@Test
public void testGetModes() {
assertEquals(one.getModes(),"Obstacles | Increasing Speed | Timed | Autoreplay");
assertEquals(two.getModes(),"Obstacles | Timed | Autoreplay");
assertEquals(three.getModes(),"Obstacles | Increasing Speed");
assertEquals(four.getModes(),"None");
}
@Test
public void testGetDate() {
assertEquals(one.getDate(),"3/15/2021");
assertEquals(two.getDate(),"1/28/2021");
assertEquals(three.getDate(),"2/10/2021");
assertEquals(four.getDate(),"2/5/2021");
}
@Test
public void testGetScore() {
assertEquals((int) one.getScore(),5);
assertEquals((int) two.getScore(),10);
assertEquals((int) three.getScore(),1);
assertEquals((int) four.getScore(),30);
}
@Test
public void testCompareTo() {
assertEquals(one.compareTo(two),1);
assertEquals(two.compareTo(three),-1);
assertEquals(three.compareTo(four),1);
}
@Test
public void testToString() {
assertEquals(one.toString(),"Obstacles | Increasing Speed | Timed | Autoreplay,3/15/2021,5");
assertEquals(two.toString(),"Obstacles | Timed | Autoreplay,1/28/2021,10");
assertEquals(three.toString(),"Obstacles | Increasing Speed,2/10/2021,1");
assertEquals(four.toString(),"None,2/5/2021,30");
}
}
import static org.junit.Assert.*;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
public class testTuple {
Tuple one;
Tuple two;
@Before
public void setUp() throws Exception {
one = new Tuple(1,2);
two = new Tuple(100,100);
}
@After
public void tearDown() throws Exception {
one = null;
two = null;
}
@Test
public void testChangeData() {
one.changeData(50, 50);
assertEquals(one.getX(), 50);
assertEquals(one.getY(), 50);
two.changeData(1, 100);
assertEquals(two.getX(), 1);
assertEquals(two.getY(), 100);
}
@Test
public void testGetX() {
assertEquals(one.getX(), 1);
assertEquals(two.getX(), 100);
}
@Test
public void testGetY() {
assertEquals(one.getY(), 2);
assertEquals(two.getY(), 100);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment