Coverage Summary for Class: UtilitiesTest (io.team9.game.tests.AI.utils)
| Class | Class, % | Method, % | Line, % |
|---|---|---|---|
| UtilitiesTest | 100% (1/1) | 100% (5/5) | 100% (29/29) |
1 package io.team9.game.tests.AI.utils; 2 3 import com.badlogic.gdx.backends.headless.HeadlessApplication; 4 import com.badlogic.gdx.math.Vector2; 5 import com.mygdx.game.Entitys.CannonBall; 6 import com.mygdx.game.Entitys.Ship; 7 import com.mygdx.game.Managers.RenderingManager; 8 import com.mygdx.utils.Utilities; 9 import io.team9.game.tests.GdxTestRunner; 10 import org.junit.Test; 11 import org.junit.runner.RunWith; 12 13 import java.awt.*; 14 import java.util.ArrayList; 15 16 import static org.junit.Assert.*; 17 18 @RunWith(GdxTestRunner.class) 19 public class UtilitiesTest { 20 @Test 21 public void angleToVectorTest() { 22 Vector2 v = new Vector2(0,0); 23 Vector2 a = new Vector2((float)-0.89399666,(float)-0.44807363); 24 assertEquals(Utilities.angleToVector(v,90),a); 25 26 } 27 28 @Test 29 public void roundTest(){ 30 Vector2 v = new Vector2(0,0); 31 Vector2 a = new Vector2(0,0); 32 assertEquals(Utilities.round(v),a); 33 v.x= (float)0.4999; 34 v.y= (float)0.4999; 35 assertEquals("Round down",Utilities.round(v),a); 36 v.x= (float)-0.5; 37 v.y= (float)-0.5; 38 assertEquals("Round Up",Utilities.round(v),a); 39 40 } 41 42 @Test 43 public void RandomPosTest(){ 44 float max = 17; 45 float min =-5; 46 Vector2 v = Utilities.randomPos(min,max); 47 assertTrue((min<=v.x)&(v.x<max)&(min<=v.y)&(v.y<max) ); 48 v = Utilities.randomPos(min,max); 49 assertTrue((min<=v.x)&(v.x<max)&(min<=v.y)&(v.y<max) ); 50 v = Utilities.randomPos(min,max); 51 assertTrue((min<=v.x)&(v.x<max)&(min<=v.y)&(v.y<max) ); 52 v = Utilities.randomPos(min,max); 53 assertTrue((min<=v.x)&(v.x<max)&(min<=v.y)&(v.y<max) ); 54 } 55 56 @Test 57 public void ContainsTest(){ 58 ArrayList<String> names = new ArrayList<String>(); 59 names.add("Bob"); 60 names.add("Brian"); 61 names.add("Ann"); 62 assertTrue("Should Return true",Utilities.contains(names,"Ann")); 63 assertFalse("Should Return false",Utilities.contains(names,"Lucy")); 64 65 } 66 67 68 69 } 70 71