forked from libgdx/libgdx
/
Vector2Test.java
38 lines (29 loc) · 935 Bytes
/
Vector2Test.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package com.badlogic.gdx.math;
import static org.junit.Assert.*;
import org.junit.Test;
public class Vector2Test {
@Test
public void testToString () {
assertEquals("(-5.0,42.00055)", new Vector2(-5f, 42.00055f).toString());
}
@Test
public void testFromString () {
assertEquals(new Vector2(-5f, 42.00055f), new Vector2().fromString("(-5,42.00055)"));
}
@Test
public void testAngle() {
assertEquals(270f, new Vector2(0, -1f).angleDeg(), MathUtils.FLOAT_ROUNDING_ERROR);
}
@Test
public void testAngleRelative() {
assertEquals(270f, new Vector2(0, -1f).angleDeg(Vector2.X), MathUtils.FLOAT_ROUNDING_ERROR);
}
@Test
public void testAngleRad() {
assertEquals(- MathUtils.PI / 2f, new Vector2(0, -1f).angleRad(), MathUtils.FLOAT_ROUNDING_ERROR);
}
@Test
public void testAngleRadRelative() {
assertEquals(- MathUtils.PI / 2f, new Vector2(0, -1f).angleRad(Vector2.X), MathUtils.FLOAT_ROUNDING_ERROR);
}
}