5
5
import java .util .Map ;
6
6
7
7
import org .junit .jupiter .api .Disabled ;
8
+ import org .junit .jupiter .api .DisplayName ;
8
9
import org .junit .jupiter .api .Test ;
9
10
10
11
public class SgfParsingTest {
11
12
12
13
@ Test
14
+ @ DisplayName ("empty input" )
13
15
public void emptyInput () {
14
16
String input = "" ;
15
17
assertThatExceptionOfType (SgfParsingException .class ).as ("tree missing" )
@@ -18,6 +20,7 @@ public void emptyInput() {
18
20
19
21
@ Test
20
22
@ Disabled ("Remove to run test" )
23
+ @ DisplayName ("tree with no nodes" )
21
24
public void treeWithNoNodes () {
22
25
String input = "()" ;
23
26
assertThatExceptionOfType (SgfParsingException .class )
@@ -27,6 +30,7 @@ public void treeWithNoNodes() {
27
30
28
31
@ Test
29
32
@ Disabled ("Remove to run test" )
33
+ @ DisplayName ("node without tree" )
30
34
public void nodeWithoutTree () {
31
35
String input = ";" ;
32
36
assertThatExceptionOfType (SgfParsingException .class ).as ("tree missing" )
@@ -35,6 +39,7 @@ public void nodeWithoutTree() {
35
39
36
40
@ Test
37
41
@ Disabled ("Remove to run test" )
42
+ @ DisplayName ("node without properties" )
38
43
public void nodeWithoutProperties () throws SgfParsingException {
39
44
String input = "(;)" ;
40
45
SgfNode expected = new SgfNode ();
@@ -44,6 +49,7 @@ public void nodeWithoutProperties() throws SgfParsingException {
44
49
45
50
@ Test
46
51
@ Disabled ("Remove to run test" )
52
+ @ DisplayName ("single node tree" )
47
53
public void singleNodeTree () throws SgfParsingException {
48
54
String input = "(;A[B])" ;
49
55
SgfNode expected = new SgfNode (Map .of ("A" , List .of ("B" )));
@@ -53,6 +59,7 @@ public void singleNodeTree() throws SgfParsingException {
53
59
54
60
@ Test
55
61
@ Disabled ("Remove to run test" )
62
+ @ DisplayName ("multiple properties" )
56
63
public void multipleProperties () throws SgfParsingException {
57
64
String input = "(;A[b]C[d])" ;
58
65
SgfNode expected = new SgfNode (Map .of ("A" , List .of ("b" ),
@@ -63,6 +70,7 @@ public void multipleProperties() throws SgfParsingException {
63
70
64
71
@ Test
65
72
@ Disabled ("Remove to run test" )
73
+ @ DisplayName ("properties without delimiter" )
66
74
public void propertiesWithoutDelimiter () {
67
75
String input = "(;A)" ;
68
76
assertThatExceptionOfType (SgfParsingException .class ).as ("properties without delimiter" )
@@ -71,6 +79,7 @@ public void propertiesWithoutDelimiter() {
71
79
72
80
@ Test
73
81
@ Disabled ("Remove to run test" )
82
+ @ DisplayName ("all lowercase property" )
74
83
public void allLowercaseProperty () {
75
84
String input = "(;a[b])" ;
76
85
assertThatExceptionOfType (SgfParsingException .class ).as ("property must be in uppercase" )
@@ -79,6 +88,7 @@ public void allLowercaseProperty() {
79
88
80
89
@ Test
81
90
@ Disabled ("Remove to run test" )
91
+ @ DisplayName ("upper and lowercase property" )
82
92
public void upperAndLowercaseProperty () {
83
93
String input = "(;Aa[b])" ;
84
94
assertThatExceptionOfType (SgfParsingException .class ).as ("property must be in uppercase" )
@@ -87,6 +97,7 @@ public void upperAndLowercaseProperty() {
87
97
88
98
@ Test
89
99
@ Disabled ("Remove to run test" )
100
+ @ DisplayName ("two nodes" )
90
101
public void twoNodes () throws SgfParsingException {
91
102
String input = "(;A[B];B[C])" ;
92
103
SgfNode expected = new SgfNode (Map .of ("A" , List .of ("B" )),
@@ -99,6 +110,7 @@ public void twoNodes() throws SgfParsingException {
99
110
100
111
@ Test
101
112
@ Disabled ("Remove to run test" )
113
+ @ DisplayName ("two child trees" )
102
114
public void twoChildTrees () throws SgfParsingException {
103
115
String input = "(;A[B](;B[C])(;C[D]))" ;
104
116
SgfNode expected = new SgfNode (Map .of ("A" , List .of ("B" )),
@@ -112,6 +124,7 @@ public void twoChildTrees() throws SgfParsingException {
112
124
113
125
@ Test
114
126
@ Disabled ("Remove to run test" )
127
+ @ DisplayName ("multiple property values" )
115
128
public void multiplePropertyValues () throws SgfParsingException {
116
129
String input = "(;A[b][c][d])" ;
117
130
SgfNode expected = new SgfNode (Map .of ("A" , List .of ("b" , "c" , "d" )));
@@ -121,6 +134,7 @@ public void multiplePropertyValues() throws SgfParsingException {
121
134
122
135
@ Test
123
136
@ Disabled ("Remove to run test" )
137
+ @ DisplayName ("within property values, whitespace characters such as tab are converted to spaces" )
124
138
public void withinPropertyValueWhitespace () throws SgfParsingException {
125
139
String input = "(;A[hello\t \t world])" ;
126
140
SgfNode expected = new SgfNode (Map .of ("A" , List .of ("hello world" )));
@@ -130,6 +144,7 @@ public void withinPropertyValueWhitespace() throws SgfParsingException {
130
144
131
145
@ Test
132
146
@ Disabled ("Remove to run test" )
147
+ @ DisplayName ("within property values, newlines remain as newlines" )
133
148
public void withinPropertyValueNewline () throws SgfParsingException {
134
149
String input = "(;A[hello\n \n world])" ;
135
150
SgfNode expected = new SgfNode (Map .of ("A" , List .of ("hello\n \n world" )));
@@ -139,6 +154,7 @@ public void withinPropertyValueNewline() throws SgfParsingException {
139
154
140
155
@ Test
141
156
@ Disabled ("Remove to run test" )
157
+ @ DisplayName ("escaped closing bracket within property value becomes just a closing bracket" )
142
158
public void escapedClosingBracket () throws SgfParsingException {
143
159
String input = "(;A[\\ ]])" ;
144
160
SgfNode expected = new SgfNode (Map .of ("A" , List .of ("]" )));
@@ -148,6 +164,7 @@ public void escapedClosingBracket() throws SgfParsingException {
148
164
149
165
@ Test
150
166
@ Disabled ("Remove to run test" )
167
+ @ DisplayName ("escaped backslash in property value becomes just a backslash" )
151
168
public void escapedBacklash () throws SgfParsingException {
152
169
String input = "(;A[\\ \\ ])" ;
153
170
SgfNode expected = new SgfNode (Map .of ("A" , List .of ("\\ " )));
@@ -157,6 +174,7 @@ public void escapedBacklash() throws SgfParsingException {
157
174
158
175
@ Test
159
176
@ Disabled ("Remove to run test" )
177
+ @ DisplayName ("opening bracket within property value doesn't need to be escaped" )
160
178
public void openingBracketNeedNotToBeEscaped () throws SgfParsingException {
161
179
String input = "(;A[x[y\\ ]z][foo]B[bar];C[baz])" ;
162
180
SgfNode expected = new SgfNode (Map .of ("A" , List .of ("x[y]z" , "foo" ),
@@ -170,6 +188,7 @@ public void openingBracketNeedNotToBeEscaped() throws SgfParsingException {
170
188
171
189
@ Test
172
190
@ Disabled ("Remove to run test" )
191
+ @ DisplayName ("semicolon in property value doesn't need to be escaped" )
173
192
public void semicolonNeedNotToBeEscaped () throws SgfParsingException {
174
193
String input = "(;A[a;b][foo]B[bar];C[baz])" ;
175
194
SgfNode expected = new SgfNode (Map .of ("A" , List .of ("a;b" , "foo" ),
@@ -183,6 +202,7 @@ public void semicolonNeedNotToBeEscaped() throws SgfParsingException {
183
202
184
203
@ Test
185
204
@ Disabled ("Remove to run test" )
205
+ @ DisplayName ("parentheses in property value don't need to be escaped" )
186
206
public void paranthesesNeedNotToBeEscaped () throws SgfParsingException {
187
207
String input = "(;A[x(y)z][foo]B[bar];C[baz])" ;
188
208
SgfNode expected = new SgfNode (Map .of ("A" , List .of ("x(y)z" , "foo" ),
@@ -196,6 +216,7 @@ public void paranthesesNeedNotToBeEscaped() throws SgfParsingException {
196
216
197
217
@ Test
198
218
@ Disabled ("Remove to run test" )
219
+ @ DisplayName ("escaped tab in property value is converted to space" )
199
220
public void escapedTab () throws SgfParsingException {
200
221
String input = "(;A[hello\\ \t world])" ;
201
222
SgfNode expected = new SgfNode (Map .of ("A" , List .of ("hello world" )));
@@ -205,6 +226,7 @@ public void escapedTab() throws SgfParsingException {
205
226
206
227
@ Test
207
228
@ Disabled ("Remove to run test" )
229
+ @ DisplayName ("escaped newline in property value is converted to nothing at all" )
208
230
public void escapedNewline () throws SgfParsingException {
209
231
String input = "(;A[hello\\ \n world])" ;
210
232
SgfNode expected = new SgfNode (Map .of ("A" , List .of ("helloworld" )));
@@ -215,6 +237,7 @@ public void escapedNewline() throws SgfParsingException {
215
237
216
238
@ Test
217
239
@ Disabled ("Remove to run test" )
240
+ @ DisplayName ("escaped t and n in property value are just letters, not whitespace" )
218
241
public void escapedTAndN () throws SgfParsingException {
219
242
String input = "(;A[\\ t = t and \\ n = n])" ;
220
243
SgfNode expected = new SgfNode (Map .of ("A" , List .of ("t = t and n = n" )));
@@ -225,6 +248,7 @@ public void escapedTAndN() throws SgfParsingException {
225
248
226
249
@ Test
227
250
@ Disabled ("Remove to run test" )
251
+ @ DisplayName ("mixing various kinds of whitespace and escaped characters in property value" )
228
252
public void mixOfEscapedCharactersAndWhitespaces () throws SgfParsingException {
229
253
String input = "(;A[\\ ]b\n c\\ \n d\t \t e\\ \\ \\ \n \\ ]])" ;
230
254
SgfNode expected = new SgfNode (Map .of ("A" , List .of ("]b\n cd e\\ ]" )));
0 commit comments