-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathAddressTest.java
More file actions
46 lines (33 loc) · 1.27 KB
/
AddressTest.java
File metadata and controls
46 lines (33 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
import junit.framework.*;
public class AddressTest extends TestCase {
public void testAddress() throws Exception {
String street = "123 fake st", city = "Springfield", postalCode ="j2j4j5";
int unit = 1;
Address x = new Address(street,city,postalCode);
String expected = street + " " + city + " " + postalCode;
String actual = x.toString();
Assert.assertEquals(expected, actual);
Address y = new Address(unit,street,city,postalCode);
actual = y.toString();
expected = Integer.toString(unit)+ " " + street + " " + city + " " + postalCode;
Assert.assertEquals(expected, actual);
}
public void testToString() throws Exception{
Address x = new Address("1","2","3");
String actual = x.toString();
String expected = "1 2 3";
Assert.assertEquals(expected, actual);
Address y = new Address(2,"5 fake st","City","1q1q1q");
actual = y.toString();
expected = "2 5 fake st city 1q1q1q";
Assert.assertEquals(expected, actual);
}
public void testEquals() throws Exception {
String street = "123 fake st", city = "Springfield", postalCode ="j2j4j5";
int unit = 1;
Address x = new Address(unit,street,city,postalCode);
Address y = new Address(street,city,postalCode);
Assert.assertFalse(x.equals(y));
Assert.assertTrue(x.equals(x));
}
}