-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathConnectorTest.java
72 lines (62 loc) · 1.35 KB
/
ConnectorTest.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
63
64
65
66
67
68
69
70
71
72
import static org.junit.Assert.*;
import org.junit.Test;
public class ConnectorTest {
@Test
public void testValidToConnector ( ){
Connector c = Connector.toConnector("12");
assertEquals(c.toString(),"12");
}
@Test
public void testWhitespacedToConnector ( ){
Connector c = Connector.toConnector(" 12 ");
assertEquals(c.toString(),"12");
}
@Test
public void testInvalidWhitespacedToConnector ( ){
boolean caught = false;
try{
@SuppressWarnings("unused")
Connector c = Connector.toConnector(" 1 2 ");
}
catch (IllegalFormatException e){
caught = true;
}
assertTrue(caught);
}
@Test
public void testOutOfRangeToConnector ( ){
boolean caught = false;
try{
@SuppressWarnings("unused")
Connector c = Connector.toConnector(" 9 2 ");
}
catch (IllegalFormatException e){
caught = true;
}
assertTrue(caught);
}
@Test
public void testTooManyToConnector ( ){
boolean caught = false;
try{
@SuppressWarnings("unused")
Connector c = Connector.toConnector(" 234 ");
}
catch (IllegalFormatException e){
caught = true;
}
assertTrue(caught);
}
@Test
public void testEqualPointsToConnector ( ){
boolean caught = false;
try{
@SuppressWarnings("unused")
Connector c = Connector.toConnector(" 33 ");
}
catch (IllegalFormatException e){
caught = true;
}
assertTrue(caught);
}
}