forked from Kotlin-Polytech/FromKotlinToJava
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathColoredPointTest.java
More file actions
49 lines (41 loc) · 1.27 KB
/
Copy pathColoredPointTest.java
File metadata and controls
49 lines (41 loc) · 1.27 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
package part2.point;
import org.junit.Test;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
import java.util.function.Predicate;
import static org.junit.Assert.*;
public class ColoredPointTest {
@Test
public void cloneTest() {
ColoredPoint cp = new ColoredPoint(1.0, 2.0, 0xff0000);
ColoredPoint cp2 = cp.clone();
assertEquals(cp, cp2);
}
@Test
public void equalsTest() {
Point p1 = new Point(1.0, 2.0);
ColoredPoint p3 = new ColoredPoint(1.0, 2.0, 0xff0000);
assertFalse(p1.equals(p3));
assertFalse(p3.equals(p1));
Set<Point> set = new HashSet<>();
set.add(p3);
set.add(p1);
assertEquals(2, set.size());
}
@Test
public void removeIfTest() {
Collection<ColoredPoint> collection = new ArrayList<>();
collection.add(new ColoredPoint(1.0, 2.0, 0xff0000));
collection.add(new ColoredPoint(-1.0, -2.0, 0x0000ff));
//noinspection Convert2Lambda
collection.removeIf(new Predicate<Point>() {
@Override
public boolean test(Point point) {
return point.getX() > 0.0;
}
});
assertEquals(1, collection.size());
}
}