-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPointEqualTest.java
62 lines (50 loc) · 1.47 KB
/
PointEqualTest.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package testingEquals;
import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;
import org.junit.Ignore;
import org.junit.Test;
public class PointEqualTest {
@Test public void normalPointEqualsExpections() {
Point p1 = new Point(10,20);
Point p2 = new Point(10,20);
Point dif = new Point(10,30);
assertEquals(p1,p2);
assertEquals(p2,p1);
assertEquals(p1,p1);
assertFalse(p1.equals(dif));
assertFalse(dif.equals(p1));
}
@Test public void normalPointExtraEqualsExpections() {
PointExtra p1 = new PointExtra(10,20,30);
PointExtra p2 = new PointExtra(10,20,30);
PointExtra dif1 = new PointExtra(10,20,20);
PointExtra dif2 = new PointExtra(10,10,30);
assertEquals(p1,p2);
assertEquals(p2,p1);
assertEquals(p1,p1);
assertFalse(p1.equals(dif1));
assertFalse(dif1.equals(p1));
assertFalse(p1.equals(dif2));
assertFalse(dif2.equals(p1));
}
@Test public void symmetry() {
Point p = new Point(10,20);
PointExtra pe = new PointExtra(10,20,30);
assertFalse (p.equals(pe));
assertFalse (pe.equals(p));
}
@Test public void transitivity() {
PointExtra pe1 = new PointExtra(10,20,30);
Point p = new Point(10,20);
PointExtra pe2 = new PointExtra(10,20,40);
assertFalse (pe1.equals(p));
assertFalse (p.equals(pe2));
assertFalse (pe1.equals(pe2));
}
@Test public void liskov() {
Point p = new Point(10,20);
PointNotSignficant pns = new PointNotSignficant(10,20);
assertEquals(p,pns);
assertEquals(pns,p);
}
}