Skip to content

Commit 16c1db8

Browse files
authored
sync the wordy as they had been implemented but not sync and fix / add missing unit tests & display name (#3054)
* sync the wordy as they had been implemented but not sync * fix and add displayName to unit tests for Wordy feature
1 parent 6cfa806 commit 16c1db8

File tree

3 files changed

+81
-11
lines changed

3 files changed

+81
-11
lines changed

exercises/practice/wordy/.meta/config.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"vasouv",
2222
"vivshaw",
2323
"vpondala",
24+
"Xinri",
2425
"Zaldrick"
2526
],
2627
"files": {

exercises/practice/wordy/.meta/tests.toml

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,32 @@
1-
# This is an auto-generated file. Regular comments will be removed when this
2-
# file is regenerated. Regenerating will not touch any manually added keys,
3-
# so comments can be added in a "comment" key.
1+
# This is an auto-generated file.
2+
#
3+
# Regenerating this file via `configlet sync` will:
4+
# - Recreate every `description` key/value pair
5+
# - Recreate every `reimplements` key/value pair, where they exist in problem-specifications
6+
# - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion)
7+
# - Preserve any other key/value pair
8+
#
9+
# As user-added comments (using the # character) will be removed when this file
10+
# is regenerated, comments can be added via a `comment` key.
411

512
[88bf4b28-0de3-4883-93c7-db1b14aa806e]
613
description = "just a number"
714

15+
[18983214-1dfc-4ebd-ac77-c110dde699ce]
16+
description = "just a zero"
17+
18+
[607c08ee-2241-4288-916d-dae5455c87e6]
19+
description = "just a negative number"
20+
821
[bb8c655c-cf42-4dfc-90e0-152fcfd8d4e0]
922
description = "addition"
1023

24+
[bb9f2082-171c-46ad-ad4e-c3f72087c1b5]
25+
description = "addition with a left hand zero"
26+
27+
[6fa05f17-405a-4742-80ae-5d1a8edb0d5d]
28+
description = "addition with a right hand zero"
29+
1130
[79e49e06-c5ae-40aa-a352-7a3a01f70015]
1231
description = "more addition"
1332

exercises/practice/wordy/src/test/java/WordProblemSolverTest.java

Lines changed: 58 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import org.junit.jupiter.api.Disabled;
2+
import org.junit.jupiter.api.DisplayName;
23
import org.junit.jupiter.api.Test;
34

45
import static org.assertj.core.api.Assertions.assertThat;
@@ -9,129 +10,175 @@ public class WordProblemSolverTest {
910
WordProblemSolver solver = new WordProblemSolver();
1011

1112
@Test
13+
@DisplayName("just a number")
1214
public void testJustANumber() {
1315
assertThat(solver.solve("What is 5?")).isEqualTo(5);
1416
}
1517

18+
@Test
19+
@DisplayName("just a zero")
20+
public void testJustAZero() {
21+
assertThat(solver.solve("What is 0?")).isEqualTo(0);
22+
}
23+
24+
@Test
25+
@DisplayName("just a negative number")
26+
public void testJustANegativeNumber() {
27+
assertThat(solver.solve("What is -123?")).isEqualTo(-123);
28+
}
29+
1630
@Disabled("Remove to run test")
1731
@Test
32+
@DisplayName("addition")
1833
public void testSingleAddition1() {
1934
assertThat(solver.solve("What is 1 plus 1?")).isEqualTo(2);
2035
}
2136

2237
@Disabled("Remove to run test")
2338
@Test
39+
@DisplayName("addition with a left hand zero")
40+
public void testAdditionWithALeftHandZero() {
41+
assertThat(solver.solve("What is 0 plus 2?")).isEqualTo(2);
42+
}
43+
44+
@Disabled("Remove to run test")
45+
@Test
46+
@DisplayName("addition with a right hand zero")
47+
public void testAdditionWithARightHandZero() {
48+
assertThat(solver.solve("What is 3 plus 0?")).isEqualTo(3);
49+
}
50+
51+
@Disabled("Remove to run test")
52+
@Test
53+
@DisplayName("more addition")
2454
public void testSingleAddition2() {
2555
assertThat(solver.solve("What is 53 plus 2?")).isEqualTo(55);
2656
}
2757

2858
@Disabled("Remove to run test")
2959
@Test
60+
@DisplayName("addition with negative numbers")
3061
public void testSingleAdditionWithNegativeNumbers() {
3162
assertThat(solver.solve("What is -1 plus -10?")).isEqualTo(-11);
3263
}
3364

3465
@Disabled("Remove to run test")
3566
@Test
67+
@DisplayName("large addition")
3668
public void testSingleAdditionOfLargeNumbers() {
3769
assertThat(solver.solve("What is 123 plus 45678?")).isEqualTo(45801);
3870
}
3971

4072
@Disabled("Remove to run test")
4173
@Test
74+
@DisplayName("subtraction")
4275
public void testSingleSubtraction() {
4376
assertThat(solver.solve("What is 4 minus -12?")).isEqualTo(16);
4477
}
4578

4679
@Disabled("Remove to run test")
4780
@Test
81+
@DisplayName("multiplication")
4882
public void testSingleMultiplication() {
4983
assertThat(solver.solve("What is -3 multiplied by 25?")).isEqualTo(-75);
5084
}
5185

5286
@Disabled("Remove to run test")
5387
@Test
88+
@DisplayName("division")
5489
public void testSingleDivision() {
5590
assertThat(solver.solve("What is 33 divided by -3?")).isEqualTo(-11);
5691
}
5792

5893
@Disabled("Remove to run test")
5994
@Test
95+
@DisplayName("multiple additions")
6096
public void testMultipleAdditions() {
6197
assertThat(solver.solve("What is 1 plus 1 plus 1?")).isEqualTo(3);
6298
}
6399

64100
@Disabled("Remove to run test")
65101
@Test
102+
@DisplayName("addition and subtraction")
66103
public void testAdditionThenSubtraction() {
67104
assertThat(solver.solve("What is 1 plus 5 minus -2?")).isEqualTo(8);
68105
}
69106

70107
@Disabled("Remove to run test")
71108
@Test
109+
@DisplayName("multiple subtraction")
72110
public void testMultipleSubtractions() {
73111
assertThat(solver.solve("What is 20 minus 4 minus 13?")).isEqualTo(3);
74112
}
75113

76114
@Disabled("Remove to run test")
77115
@Test
116+
@DisplayName("subtraction then addition")
78117
public void testSubtractionThenAddition() {
79118
assertThat(solver.solve("What is 17 minus 6 plus 3?")).isEqualTo(14);
80119
}
81120

82121
@Disabled("Remove to run test")
83122
@Test
123+
@DisplayName("multiple multiplication")
84124
public void testMultipleMultiplications() {
85125
assertThat(solver.solve("What is 2 multiplied by -2 multiplied by 3?")).isEqualTo(-12);
86126
}
87127

88128
@Disabled("Remove to run test")
89129
@Test
130+
@DisplayName("addition and multiplication")
90131
public void testAdditionThenMultiplication() {
91132
assertThat(solver.solve("What is -3 plus 7 multiplied by -2?")).isEqualTo(-8);
92133
}
93134

94135
@Disabled("Remove to run test")
95136
@Test
137+
@DisplayName("multiple division")
96138
public void testMultipleDivisions() {
97139
assertThat(solver.solve("What is -12 divided by 2 divided by -3?")).isEqualTo(2);
98140
}
99141

100142
@Disabled("Remove to run test")
101143
@Test
144+
@DisplayName("unknown operation")
102145
public void testUnknownOperation() {
103146
assertThatExceptionOfType(IllegalArgumentException.class)
104-
.isThrownBy(() -> solver.solve("What is 52 cubed?"))
105-
.withMessage("I'm sorry, I don't understand the question!");
147+
.isThrownBy(() -> solver.solve("What is 52 cubed?"))
148+
.withMessage("I'm sorry, I don't understand the question!");
106149
}
107150

108151
@Disabled("Remove to run test")
109152
@Test
153+
@DisplayName("Non math question")
110154
public void testNonMathQuestion() {
111155
// See https://en.wikipedia.org/wiki/President_of_the_United_States if you really need to know!
112156
assertThatExceptionOfType(IllegalArgumentException.class)
113-
.isThrownBy(() -> solver.solve("Who is the President of the United States?"))
114-
.withMessage("I'm sorry, I don't understand the question!");
157+
.isThrownBy(() -> solver.solve("Who is the President of the United States?"))
158+
.withMessage("I'm sorry, I don't understand the question!");
115159
}
116160

117161
@Disabled("Remove to run test")
118162
@Test
163+
@DisplayName("reject problem missing an operand")
119164
public void testMissingAnOperand() {
120165
assertThatExceptionOfType(IllegalArgumentException.class)
121-
.isThrownBy(() -> solver.solve("What is 1 plus?"))
122-
.withMessage("I'm sorry, I don't understand the question!");
166+
.isThrownBy(() -> solver.solve("What is 1 plus?"))
167+
.withMessage("I'm sorry, I don't understand the question!");
123168
}
124169

125170
@Disabled("Remove to run test")
126171
@Test
172+
@DisplayName("reject problem with no operands or operator")
127173
public void testNoOperandsOrOperators() {
128174
assertThatExceptionOfType(IllegalArgumentException.class)
129-
.isThrownBy(() -> solver.solve("What is?"))
130-
.withMessage("I'm sorry, I don't understand the question!");
175+
.isThrownBy(() -> solver.solve("What is?"))
176+
.withMessage("I'm sorry, I don't understand the question!");
131177
}
132178

133179
@Disabled("Remove to run test")
134180
@Test
181+
@DisplayName("reject two operations in a row")
135182
public void testTwoOperationsInARow() {
136183
assertThatExceptionOfType(IllegalArgumentException.class)
137184
.isThrownBy(() -> solver.solve("What is 1 plus plus 2?"))
@@ -140,6 +187,7 @@ public void testTwoOperationsInARow() {
140187

141188
@Disabled("Remove to run test")
142189
@Test
190+
@DisplayName("reject two numbers in a row")
143191
public void testTwoNumbersAfterOperation() {
144192
assertThatExceptionOfType(IllegalArgumentException.class)
145193
.isThrownBy(() -> solver.solve("What is 1 plus 2 1?"))
@@ -148,6 +196,7 @@ public void testTwoNumbersAfterOperation() {
148196

149197
@Disabled("Remove to run test")
150198
@Test
199+
@DisplayName("reject postfix notation")
151200
public void testPostfixNotation() {
152201
assertThatExceptionOfType(IllegalArgumentException.class)
153202
.isThrownBy(() -> solver.solve("What is 1 2 plus?"))
@@ -156,6 +205,7 @@ public void testPostfixNotation() {
156205

157206
@Disabled("Remove to run test")
158207
@Test
208+
@DisplayName("reject prefix notation")
159209
public void testPrefixNotation() {
160210
assertThatExceptionOfType(IllegalArgumentException.class)
161211
.isThrownBy(() -> solver.solve("What is plus 1 2?"))

0 commit comments

Comments
 (0)