-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathPointTest.java
More file actions
68 lines (57 loc) · 2.1 KB
/
PointTest.java
File metadata and controls
68 lines (57 loc) · 2.1 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package ch.usi.si.seart.treesitter;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
class PointTest extends BaseTest {
@Test
void testIsOrigin() {
Assertions.assertTrue(_0_0_.isOrigin());
}
@Test
void testIsNotOrigin() {
Assertions.assertFalse(_1_0_.isOrigin());
Assertions.assertFalse(_0_1_.isOrigin());
Assertions.assertFalse(_1_1_.isOrigin());
Assertions.assertFalse(_2_2_.isOrigin());
}
@Test
void testCompareTo() {
List<Point> sorted = List.of(new Point(-1, -1), new Point(-1, 0), _0_0_, _0_1_, _1_0_, _1_1_);
ArrayList<Point> unsorted = new ArrayList<>(sorted);
Collections.shuffle(unsorted);
Collections.sort(unsorted);
Assertions.assertEquals(sorted, unsorted);
}
@Test
void testCompareToThrows() {
Assertions.assertThrows(NullPointerException.class, () -> _0_0_.compareTo(null));
}
@Test
void testAdd() {
Assertions.assertEquals(_1_1_, _0_0_.add(_1_1_));
Assertions.assertEquals(_1_1_, _1_1_.add(_0_0_));
Assertions.assertEquals(_0_0_, new Point(-1, -1).add(_1_1_));
Assertions.assertEquals(_2_2_, _1_1_.add(_1_1_));
}
@Test
void testSubtract() {
Assertions.assertEquals(_0_0_, _1_1_.subtract(_1_1_));
Assertions.assertEquals(_1_1_, _1_1_.subtract(_0_0_));
Assertions.assertEquals(new Point(-1, -1), _0_0_.subtract(_1_1_));
Assertions.assertEquals(new Point(-2, -2), new Point(-1, -1).subtract(_1_1_));
}
@Test
void testMultiply() {
Assertions.assertEquals(_0_0_, _0_0_.multiply(2));
Assertions.assertEquals(_0_0_, _1_1_.multiply(0));
Assertions.assertEquals(_1_1_, _1_1_.multiply(1));
Assertions.assertEquals(_2_2_, _1_1_.multiply(2));
}
@Test
void testThrows() {
Assertions.assertThrows(NullPointerException.class, () -> _0_0_.add(null));
Assertions.assertThrows(NullPointerException.class, () -> _0_0_.subtract(null));
}
}