forked from ChrisMayfield/ThinkJavaCode2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPointTest.java
More file actions
45 lines (40 loc) · 1 KB
/
PointTest.java
File metadata and controls
45 lines (40 loc) · 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
import static org.junit.Assert.*;
import org.junit.Test;
/**
* Tests the Point class.
*/
public class PointTest {
/**
* Tests the distance method.
*/
@Test
public void testDistance() {
Point p1 = new Point(0, 0);
Point p2 = new Point(3, 4);
assertEquals(0.0, p1.distance(p1), Point.DELTA);
assertEquals(5.0, p1.distance(p2), Point.DELTA);
}
/**
* Tests the equals method.
*/
@Test
public void testEquals() {
Point p1 = new Point(0, 0);
Point p2 = new Point(0, 0);
Point p3 = new Point(3, 4);
Point p4 = new Point(3, 5);
assertTrue(p1.equals(p2));
assertFalse(p2.equals(p3));
assertFalse(p3.equals(p4));
}
/**
* Tests the toString method.
*/
@Test
public void testToString() {
Point p1 = new Point(0, 0);
Point p2 = new Point(3, 4);
assertEquals("(0.0, 0.0)", p1.toString());
assertEquals("(3.0, 4.0)", p2.toString());
}
}