-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMatchingBracketsTest.java
More file actions
90 lines (75 loc) · 2.47 KB
/
Copy pathMatchingBracketsTest.java
File metadata and controls
90 lines (75 loc) · 2.47 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
public class MatchingBracketsTest {
MatchingBrackets doesItWork = new MatchingBrackets();
@Test
//{} - True
public void requiredTest1() {
Assertions.assertTrue(doesItWork.isMatch("{}"));
}
@Test
//}{ - False (closed bracket can't proceed all open brackets.)
public void requiredTest2() {
Assertions.assertFalse(doesItWork.isMatch("}{"));
}
@Test
//{{} - False (one bracket pair was not closed)
public void requiredTest3() {
Assertions.assertFalse(doesItWork.isMatch("{{}"));
}
@Test
//"" - True. (no brackets in the string will return True)
public void requiredTest4() {
Assertions.assertTrue(doesItWork.isMatch(""));
}
@Test
//{abc...xyz} - True (non-bracket characters are ignored appropriately)
public void requiredTest5() {
Assertions.assertTrue(doesItWork.isMatch("{abc...xyz}"));
}
@Test
//{abc.ABC.123.xyz} - True (non-bracket characters are ignored appropriately)
public void numbersOrLettersTest5() {
Assertions.assertTrue(doesItWork.isMatch("{abc.ABC.123.xyz}"));
}
@Test
//allows nested brackets
public void nestedTest() {
Assertions.assertTrue(doesItWork.isMatch("{{}}"));
}
@Test
//allows nested brackets
public void dualNestedTest() {
Assertions.assertTrue(doesItWork.isMatch("{{}{}}"));
}
@Test
//allows nested brackets
public void dualNestedWithLetterOrNumberTest() {
Assertions.assertTrue(doesItWork.isMatch("{[{}aA1{}]}"));
}
@Test
//allows nested brackets
public void dualNestedWithASpecialCharTest() {
Assertions.assertTrue(doesItWork.isMatch("{[{},*$^{}]}"));
}
@Test
//allows nested brackets with additional chars
public void nestedAndAdditionalCharsTest() {
Assertions.assertTrue(doesItWork.isMatch("{sdaf{231}ASDFA}"));
}
@Test
//allows spaces
public void spacesTest() {
Assertions.assertTrue(doesItWork.isMatch(" { sd af{ 231} ASljn DF123A}"));
}
@Test
//multiple right brackets after a matched bracket
public void trailingMultipleRightBracketsTest() {
Assertions.assertFalse(doesItWork.isMatch("{}}}{{"));
}
@Test
//Extra left brackets after a matched bracket
public void trailingLeftMultipleRightBracketsTest() {
Assertions.assertFalse(doesItWork.isMatch("{}{{}}{"));
}
}