Skip to content

Commit 330b39f

Browse files
add displayname annotations to sgf-parsing
1 parent 34c29de commit 330b39f

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

exercises/practice/sgf-parsing/src/test/java/SgfParsingTest.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@
55
import java.util.Map;
66

77
import org.junit.jupiter.api.Disabled;
8+
import org.junit.jupiter.api.DisplayName;
89
import org.junit.jupiter.api.Test;
910

1011
public class SgfParsingTest {
1112

1213
@Test
14+
@DisplayName("empty input")
1315
public void emptyInput() {
1416
String input = "";
1517
assertThatExceptionOfType(SgfParsingException.class).as("tree missing")
@@ -18,6 +20,7 @@ public void emptyInput() {
1820

1921
@Test
2022
@Disabled("Remove to run test")
23+
@DisplayName("tree with no nodes")
2124
public void treeWithNoNodes() {
2225
String input = "()";
2326
assertThatExceptionOfType(SgfParsingException.class)
@@ -27,6 +30,7 @@ public void treeWithNoNodes() {
2730

2831
@Test
2932
@Disabled("Remove to run test")
33+
@DisplayName("node without tree")
3034
public void nodeWithoutTree() {
3135
String input = ";";
3236
assertThatExceptionOfType(SgfParsingException.class).as("tree missing")
@@ -35,6 +39,7 @@ public void nodeWithoutTree() {
3539

3640
@Test
3741
@Disabled("Remove to run test")
42+
@DisplayName("node without properties")
3843
public void nodeWithoutProperties() throws SgfParsingException {
3944
String input = "(;)";
4045
SgfNode expected = new SgfNode();
@@ -44,6 +49,7 @@ public void nodeWithoutProperties() throws SgfParsingException {
4449

4550
@Test
4651
@Disabled("Remove to run test")
52+
@DisplayName("single node tree")
4753
public void singleNodeTree() throws SgfParsingException {
4854
String input = "(;A[B])";
4955
SgfNode expected = new SgfNode(Map.of("A", List.of("B")));
@@ -53,6 +59,7 @@ public void singleNodeTree() throws SgfParsingException {
5359

5460
@Test
5561
@Disabled("Remove to run test")
62+
@DisplayName("multiple properties")
5663
public void multipleProperties() throws SgfParsingException {
5764
String input = "(;A[b]C[d])";
5865
SgfNode expected = new SgfNode(Map.of("A", List.of("b"),
@@ -63,6 +70,7 @@ public void multipleProperties() throws SgfParsingException {
6370

6471
@Test
6572
@Disabled("Remove to run test")
73+
@DisplayName("properties without delimiter")
6674
public void propertiesWithoutDelimiter() {
6775
String input = "(;A)";
6876
assertThatExceptionOfType(SgfParsingException.class).as("properties without delimiter")
@@ -71,6 +79,7 @@ public void propertiesWithoutDelimiter() {
7179

7280
@Test
7381
@Disabled("Remove to run test")
82+
@DisplayName("all lowercase property")
7483
public void allLowercaseProperty() {
7584
String input = "(;a[b])";
7685
assertThatExceptionOfType(SgfParsingException.class).as("property must be in uppercase")
@@ -79,6 +88,7 @@ public void allLowercaseProperty() {
7988

8089
@Test
8190
@Disabled("Remove to run test")
91+
@DisplayName("upper and lowercase property")
8292
public void upperAndLowercaseProperty() {
8393
String input = "(;Aa[b])";
8494
assertThatExceptionOfType(SgfParsingException.class).as("property must be in uppercase")
@@ -87,6 +97,7 @@ public void upperAndLowercaseProperty() {
8797

8898
@Test
8999
@Disabled("Remove to run test")
100+
@DisplayName("two nodes")
90101
public void twoNodes() throws SgfParsingException {
91102
String input = "(;A[B];B[C])";
92103
SgfNode expected = new SgfNode(Map.of("A", List.of("B")),
@@ -99,6 +110,7 @@ public void twoNodes() throws SgfParsingException {
99110

100111
@Test
101112
@Disabled("Remove to run test")
113+
@DisplayName("two child trees")
102114
public void twoChildTrees() throws SgfParsingException {
103115
String input = "(;A[B](;B[C])(;C[D]))";
104116
SgfNode expected = new SgfNode(Map.of("A", List.of("B")),
@@ -112,6 +124,7 @@ public void twoChildTrees() throws SgfParsingException {
112124

113125
@Test
114126
@Disabled("Remove to run test")
127+
@DisplayName("multiple property values")
115128
public void multiplePropertyValues() throws SgfParsingException {
116129
String input = "(;A[b][c][d])";
117130
SgfNode expected = new SgfNode(Map.of("A", List.of("b", "c", "d")));
@@ -121,6 +134,7 @@ public void multiplePropertyValues() throws SgfParsingException {
121134

122135
@Test
123136
@Disabled("Remove to run test")
137+
@DisplayName("within property values, whitespace characters such as tab are converted to spaces")
124138
public void withinPropertyValueWhitespace() throws SgfParsingException {
125139
String input = "(;A[hello\t\tworld])";
126140
SgfNode expected = new SgfNode(Map.of("A", List.of("hello world")));
@@ -130,6 +144,7 @@ public void withinPropertyValueWhitespace() throws SgfParsingException {
130144

131145
@Test
132146
@Disabled("Remove to run test")
147+
@DisplayName("within property values, newlines remain as newlines")
133148
public void withinPropertyValueNewline() throws SgfParsingException {
134149
String input = "(;A[hello\n\nworld])";
135150
SgfNode expected = new SgfNode(Map.of("A", List.of("hello\n\nworld")));
@@ -139,6 +154,7 @@ public void withinPropertyValueNewline() throws SgfParsingException {
139154

140155
@Test
141156
@Disabled("Remove to run test")
157+
@DisplayName("escaped closing bracket within property value becomes just a closing bracket")
142158
public void escapedClosingBracket() throws SgfParsingException {
143159
String input = "(;A[\\]])";
144160
SgfNode expected = new SgfNode(Map.of("A", List.of("]")));
@@ -148,6 +164,7 @@ public void escapedClosingBracket() throws SgfParsingException {
148164

149165
@Test
150166
@Disabled("Remove to run test")
167+
@DisplayName("escaped backslash in property value becomes just a backslash")
151168
public void escapedBacklash() throws SgfParsingException {
152169
String input = "(;A[\\\\])";
153170
SgfNode expected = new SgfNode(Map.of("A", List.of("\\")));
@@ -157,6 +174,7 @@ public void escapedBacklash() throws SgfParsingException {
157174

158175
@Test
159176
@Disabled("Remove to run test")
177+
@DisplayName("opening bracket within property value doesn't need to be escaped")
160178
public void openingBracketNeedNotToBeEscaped() throws SgfParsingException {
161179
String input = "(;A[x[y\\]z][foo]B[bar];C[baz])";
162180
SgfNode expected = new SgfNode(Map.of("A", List.of("x[y]z", "foo"),
@@ -170,6 +188,7 @@ public void openingBracketNeedNotToBeEscaped() throws SgfParsingException {
170188

171189
@Test
172190
@Disabled("Remove to run test")
191+
@DisplayName("semicolon in property value doesn't need to be escaped")
173192
public void semicolonNeedNotToBeEscaped() throws SgfParsingException {
174193
String input = "(;A[a;b][foo]B[bar];C[baz])";
175194
SgfNode expected = new SgfNode(Map.of("A", List.of("a;b", "foo"),
@@ -183,6 +202,7 @@ public void semicolonNeedNotToBeEscaped() throws SgfParsingException {
183202

184203
@Test
185204
@Disabled("Remove to run test")
205+
@DisplayName("parentheses in property value don't need to be escaped")
186206
public void paranthesesNeedNotToBeEscaped() throws SgfParsingException {
187207
String input = "(;A[x(y)z][foo]B[bar];C[baz])";
188208
SgfNode expected = new SgfNode(Map.of("A", List.of("x(y)z", "foo"),
@@ -196,6 +216,7 @@ public void paranthesesNeedNotToBeEscaped() throws SgfParsingException {
196216

197217
@Test
198218
@Disabled("Remove to run test")
219+
@DisplayName("escaped tab in property value is converted to space")
199220
public void escapedTab() throws SgfParsingException {
200221
String input = "(;A[hello\\\tworld])";
201222
SgfNode expected = new SgfNode(Map.of("A", List.of("hello world")));
@@ -205,6 +226,7 @@ public void escapedTab() throws SgfParsingException {
205226

206227
@Test
207228
@Disabled("Remove to run test")
229+
@DisplayName("escaped newline in property value is converted to nothing at all")
208230
public void escapedNewline() throws SgfParsingException {
209231
String input = "(;A[hello\\\nworld])";
210232
SgfNode expected = new SgfNode(Map.of("A", List.of("helloworld")));
@@ -215,6 +237,7 @@ public void escapedNewline() throws SgfParsingException {
215237

216238
@Test
217239
@Disabled("Remove to run test")
240+
@DisplayName("escaped t and n in property value are just letters, not whitespace")
218241
public void escapedTAndN() throws SgfParsingException {
219242
String input = "(;A[\\t = t and \\n = n])";
220243
SgfNode expected = new SgfNode(Map.of("A", List.of("t = t and n = n")));
@@ -225,6 +248,7 @@ public void escapedTAndN() throws SgfParsingException {
225248

226249
@Test
227250
@Disabled("Remove to run test")
251+
@DisplayName("mixing various kinds of whitespace and escaped characters in property value")
228252
public void mixOfEscapedCharactersAndWhitespaces() throws SgfParsingException {
229253
String input = "(;A[\\]b\nc\\\nd\t\te\\\\ \\\n\\]])";
230254
SgfNode expected = new SgfNode(Map.of("A", List.of("]b\ncd e\\ ]")));

0 commit comments

Comments
 (0)