Skip to content

Commit 5fa4d79

Browse files
committed
Finished java tests
1 parent 76b1cb4 commit 5fa4d79

File tree

10 files changed

+763
-0
lines changed

10 files changed

+763
-0
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
package vecmatlib.color;
2+
3+
import org.junit.Assert;
4+
import org.junit.Test;
5+
6+
public class TestColor {
7+
8+
@Test
9+
public void testSumValues() {
10+
Color c = new Color(0.1f, 0.2f, 0.3f, 0.5f);
11+
Assert.assertEquals(c.$plus(0.5f, 0.6f, 0.7f, 0.5f), c.add(0.5f, 0.6f, 0.7f, 0.5f));
12+
}
13+
14+
@Test
15+
public void testSumColors() {
16+
Color c1 = new Color(0.1f, 0.2f, 0.3f, 0.5f);
17+
Color c2 = new Color(0.5f, 0.6f, 0.7f, 0.5f);
18+
Assert.assertEquals(c1.$plus(c2), c1.add(c2));
19+
}
20+
21+
@Test
22+
public void testSubtractValues() {
23+
Color c = new Color(0.1f, 0.2f, 0.3f, 0.5f);
24+
Assert.assertEquals(c.$minus(0.5f, 0.6f, 0.7f, 0.5f), c.subtract(0.5f, 0.6f, 0.7f, 0.5f));
25+
}
26+
27+
@Test
28+
public void testSubtractColors() {
29+
Color c1 = new Color(0.1f, 0.2f, 0.3f, 0.5f);
30+
Color c2 = new Color(0.5f, 0.6f, 0.7f, 0.5f);
31+
Assert.assertEquals(c1.$minus(c2), c1.subtract(c2));
32+
}
33+
34+
@Test
35+
public void testMultiplyValues() {
36+
Color c = new Color(0.1f, 0.2f, 0.3f, 0.5f);
37+
Assert.assertEquals(c.$times(0.5f, 0.6f, 0.7f, 0.5f), c.blend(0.5f, 0.6f, 0.7f, 0.5f));
38+
}
39+
40+
@Test
41+
public void testMultiplyColors() {
42+
Color c1 = new Color(0.1f, 0.2f, 0.3f, 0.5f);
43+
Color c2 = new Color(0.5f, 0.6f, 0.7f, 0.5f);
44+
Assert.assertEquals(c1.$times(c2), c1.blend(c2));
45+
}
46+
47+
@Test
48+
public void testMultiplyScalar() {
49+
Color c = new Color(0.1f, 0.2f, 0.3f, 0.5f);
50+
Assert.assertEquals(c.$times(1.5f), c.multiply(1.5f));
51+
}
52+
}
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
package vecmatlib.matrix;
2+
3+
import org.junit.Assert;
4+
import org.junit.Test;
5+
import vecmatlib.vector.Vec2d;
6+
7+
public class TestMat2d {
8+
9+
@Test
10+
public void testPlus() {
11+
Mat2d a = new Mat2d(
12+
1.0, 2.0,
13+
3.0, 4.0
14+
);
15+
Mat2d b = new Mat2d(
16+
4.0, 5.0,
17+
3.0, 6.0
18+
);
19+
Assert.assertEquals(a.$plus(b), a.plus(b));
20+
}
21+
22+
@Test
23+
public void testNegated() {
24+
Mat2d m = new Mat2d(
25+
1.0, 2.0,
26+
3.0, 4.0
27+
);
28+
Assert.assertEquals(m.unary_$minus(), m.negated());
29+
}
30+
31+
@Test
32+
public void testMultiplyByScalar() {
33+
Mat2d m = new Mat2d(
34+
1.0, 2.0,
35+
3.0, 4.0
36+
);
37+
Assert.assertEquals(m.$times(1.5), m.multipliedBy(1.5));
38+
}
39+
40+
@Test
41+
public void testMultiplyVector() {
42+
Mat2d m = new Mat2d(
43+
1.0, 2.0,
44+
3.0, 4.0
45+
);
46+
Vec2d v = new Vec2d(1.5, 2.5);
47+
Assert.assertEquals(m.$times(v), m.multiply(v));
48+
}
49+
50+
@Test
51+
public void testMultiplyVectorValues() {
52+
Mat2d m = new Mat2d(
53+
1.0, 2.0,
54+
3.0, 4.0
55+
);
56+
Assert.assertEquals(m.$times(1.5, 2.5), m.multiply(1.5, 2.5));
57+
}
58+
59+
@Test
60+
public void testMultiplyMatrix() {
61+
Mat2d a = new Mat2d(
62+
1.0, 2.0,
63+
3.0, 4.0
64+
);
65+
Mat2d b = new Mat2d(
66+
4.0, 5.0,
67+
3.0, 6.0
68+
);
69+
Assert.assertEquals(a.$times(b), a.multiply(b));
70+
}
71+
}
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
package vecmatlib.matrix;
2+
3+
import org.junit.Assert;
4+
import org.junit.Test;
5+
import vecmatlib.vector.Vec2f;
6+
7+
public class TestMat2f {
8+
9+
@Test
10+
public void testPlus() {
11+
Mat2f a = new Mat2f(
12+
1.0f, 2.0f,
13+
3.0f, 4.0f
14+
);
15+
Mat2f b = new Mat2f(
16+
4.0f, 5.0f,
17+
3.0f, 6.0f
18+
);
19+
Assert.assertEquals(a.$plus(b), a.plus(b));
20+
}
21+
22+
@Test
23+
public void testNegated() {
24+
Mat2f m = new Mat2f(
25+
1.0f, 2.0f,
26+
3.0f, 4.0f
27+
);
28+
Assert.assertEquals(m.unary_$minus(), m.negated());
29+
}
30+
31+
@Test
32+
public void testMultiplyByScalar() {
33+
Mat2f m = new Mat2f(
34+
1.0f, 2.0f,
35+
3.0f, 4.0f
36+
);
37+
Assert.assertEquals(m.$times(1.5f), m.multipliedBy(1.5f));
38+
}
39+
40+
@Test
41+
public void testMultiplyVector() {
42+
Mat2f m = new Mat2f(
43+
1.0f, 2.0f,
44+
3.0f, 4.0f
45+
);
46+
Vec2f v = new Vec2f(1.5f, 2.5f);
47+
Assert.assertEquals(m.$times(v), m.multiply(v));
48+
}
49+
50+
@Test
51+
public void testMultiplyVectorValues() {
52+
Mat2f m = new Mat2f(
53+
1.0f, 2.0f,
54+
3.0f, 4.0f
55+
);
56+
Assert.assertEquals(m.$times(1.5f, 2.5f), m.multiply(1.5f, 2.5f));
57+
}
58+
59+
@Test
60+
public void testMultiplyMatrix() {
61+
Mat2f a = new Mat2f(
62+
1.0f, 2.0f,
63+
3.0f, 4.0f
64+
);
65+
Mat2f b = new Mat2f(
66+
4.0f, 5.0f,
67+
3.0f, 6.0f
68+
);
69+
Assert.assertEquals(a.$times(b), a.multiply(b));
70+
}
71+
}
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
package vecmatlib.matrix;
2+
3+
import org.junit.Assert;
4+
import org.junit.Test;
5+
import vecmatlib.vector.Vec2i;
6+
7+
public class TestMat2i {
8+
9+
@Test
10+
public void testPlus() {
11+
Mat2i a = new Mat2i(
12+
1, 2,
13+
3, 4
14+
);
15+
Mat2i b = new Mat2i(
16+
4, 5,
17+
3, 6
18+
);
19+
Assert.assertEquals(a.$plus(b), a.plus(b));
20+
}
21+
22+
@Test
23+
public void testNegated() {
24+
Mat2i m = new Mat2i(
25+
1, 2,
26+
3, 4
27+
);
28+
Assert.assertEquals(m.unary_$minus(), m.negated());
29+
}
30+
31+
@Test
32+
public void testMultiplyByScalar() {
33+
Mat2i m = new Mat2i(
34+
1, 2,
35+
3, 4
36+
);
37+
Assert.assertEquals(m.$times(2), m.multipliedBy(2));
38+
}
39+
40+
@Test
41+
public void testMultiplyVector() {
42+
Mat2i m = new Mat2i(
43+
1, 2,
44+
3, 4
45+
);
46+
Vec2i v = new Vec2i(2, 3);
47+
Assert.assertEquals(m.$times(v), m.multiply(v));
48+
}
49+
50+
@Test
51+
public void testMultiplyVectorValues() {
52+
Mat2i m = new Mat2i(
53+
1, 2,
54+
3, 4
55+
);
56+
Assert.assertEquals(m.$times(2, 3), m.multiply(2, 3));
57+
}
58+
59+
@Test
60+
public void testMultiplyMatrix() {
61+
Mat2i a = new Mat2i(
62+
1, 2,
63+
3, 4
64+
);
65+
Mat2i b = new Mat2i(
66+
4, 5,
67+
3, 6
68+
);
69+
Assert.assertEquals(a.$times(b), a.multiply(b));
70+
}
71+
}
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
package vecmatlib.matrix;
2+
3+
import org.junit.Assert;
4+
import org.junit.Test;
5+
import vecmatlib.vector.Vec3d;
6+
7+
public class TestMat3d {
8+
9+
@Test
10+
public void testPlus() {
11+
Mat3d a = new Mat3d(
12+
1.0, 2.0, 3.0,
13+
4.0, 5.0, 6.0,
14+
7.0, 8.0, 9.0
15+
);
16+
Mat3d b = new Mat3d(
17+
3.0, 6.0, 9.0,
18+
2.0, 4.0, 8.0,
19+
1.0, 5.0, 7.0
20+
);
21+
Assert.assertEquals(a.$plus(b), a.plus(b));
22+
}
23+
24+
@Test
25+
public void testNegated() {
26+
Mat3d m = new Mat3d(
27+
1.0, 2.0, 3.0,
28+
4.0, 5.0, 6.0,
29+
7.0, 8.0, 9.0
30+
);
31+
Assert.assertEquals(m.unary_$minus(), m.negated());
32+
}
33+
34+
@Test
35+
public void testMultiplyByScalar() {
36+
Mat3d m = new Mat3d(
37+
1.0, 2.0, 3.0,
38+
4.0, 5.0, 6.0,
39+
7.0, 8.0, 9.0
40+
);
41+
Assert.assertEquals(m.$times(1.5), m.multipliedBy(1.5));
42+
}
43+
44+
@Test
45+
public void testMultiplyVector() {
46+
Mat3d m = new Mat3d(
47+
1.0, 2.0, 3.0,
48+
4.0, 5.0, 6.0,
49+
7.0, 8.0, 9.0
50+
);
51+
Vec3d v = new Vec3d(1.5, 2.5, 3.5);
52+
Assert.assertEquals(m.$times(v), m.multiply(v));
53+
}
54+
55+
@Test
56+
public void testMultiplyVectorValues() {
57+
Mat3d m = new Mat3d(
58+
1.0, 2.0, 3.0,
59+
4.0, 5.0, 6.0,
60+
7.0, 8.0, 9.0
61+
);
62+
Assert.assertEquals(m.$times(1.5, 2.5, 3.5), m.multiply(1.5, 2.5, 3.5));
63+
}
64+
65+
@Test
66+
public void testMultiplyMatrix() {
67+
Mat3d a = new Mat3d(
68+
1.0, 2.0, 3.0,
69+
4.0, 5.0, 6.0,
70+
7.0, 8.0, 9.0
71+
);
72+
Mat3d b = new Mat3d(
73+
3.0, 6.0, 9.0,
74+
2.0, 4.0, 8.0,
75+
1.0, 5.0, 7.0
76+
);
77+
Assert.assertEquals(a.$times(b), a.multiply(b));
78+
}
79+
}

0 commit comments

Comments
 (0)