Skip to content

Commit 51896fc

Browse files
Finished with adding @DisplayName to alphametics, anagram, armstrong-numbers, atbash-cipher (#2990)
* alphametics, anagram, armstrong-numbers, atbash-cipher * alphametics, armstrong-numbers [no important files changed] --------- Co-authored-by: Jagdish Prajapati <[email protected]>
1 parent 544d22e commit 51896fc

File tree

4 files changed

+56
-1
lines changed

4 files changed

+56
-1
lines changed

exercises/practice/alphametics/src/test/java/AlphameticsTest.java

Lines changed: 12 additions & 1 deletion
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 java.util.Map.entry;
@@ -8,6 +9,7 @@
89
public class AlphameticsTest {
910

1011
@Test
12+
@DisplayName("puzzle with three letters")
1113
public void testThreeLetters() throws UnsolvablePuzzleException {
1214
assertThat(new Alphametics("I + BB == ILL").solve())
1315
.containsOnly(
@@ -18,6 +20,7 @@ public void testThreeLetters() throws UnsolvablePuzzleException {
1820

1921
@Disabled("Remove to run test")
2022
@Test
23+
@DisplayName("solution must have unique value for each letter")
2124
public void testUniqueValue() {
2225
Alphametics alphametics = new Alphametics("A == B");
2326

@@ -27,6 +30,7 @@ public void testUniqueValue() {
2730

2831
@Disabled("Remove to run test")
2932
@Test
33+
@DisplayName("leading zero solution is invalid")
3034
public void testLeadingZero() {
3135
Alphametics alphametics = new Alphametics("ACA + DD == BD");
3236

@@ -36,6 +40,7 @@ public void testLeadingZero() {
3640

3741
@Disabled("Remove to run test")
3842
@Test
43+
@DisplayName("puzzle with two digits final carry")
3944
public void testTwoDigitsFinalCarry() throws UnsolvablePuzzleException {
4045
assertThat(new Alphametics("A + A + A + A + A + A + A + A + A + A + A + B == BCC").solve())
4146
.containsOnly(
@@ -46,6 +51,7 @@ public void testTwoDigitsFinalCarry() throws UnsolvablePuzzleException {
4651

4752
@Disabled("Remove to run test")
4853
@Test
54+
@DisplayName("puzzle with four letters")
4955
public void testFourLetters() throws UnsolvablePuzzleException {
5056
assertThat(new Alphametics("AS + A == MOM").solve())
5157
.containsOnly(
@@ -57,6 +63,7 @@ public void testFourLetters() throws UnsolvablePuzzleException {
5763

5864
@Disabled("Remove to run test")
5965
@Test
66+
@DisplayName("puzzle with six letters")
6067
public void testSixLetters() throws UnsolvablePuzzleException {
6168
assertThat(new Alphametics("NO + NO + TOO == LATE").solve())
6269
.containsOnly(
@@ -70,6 +77,7 @@ public void testSixLetters() throws UnsolvablePuzzleException {
7077

7178
@Disabled("Remove to run test")
7279
@Test
80+
@DisplayName("puzzle with seven letters")
7381
public void testSevenLetters() throws UnsolvablePuzzleException {
7482
assertThat(new Alphametics("HE + SEES + THE == LIGHT").solve())
7583
.containsOnly(
@@ -84,6 +92,7 @@ public void testSevenLetters() throws UnsolvablePuzzleException {
8492

8593
@Disabled("Remove to run test")
8694
@Test
95+
@DisplayName("puzzle with eight letters")
8796
public void testEightLetters() throws UnsolvablePuzzleException {
8897
assertThat(new Alphametics("SEND + MORE == MONEY").solve())
8998
.containsOnly(
@@ -99,6 +108,7 @@ public void testEightLetters() throws UnsolvablePuzzleException {
99108

100109
@Disabled("Remove to run test")
101110
@Test
111+
@DisplayName("puzzle with ten letters")
102112
public void testTenLetters() throws UnsolvablePuzzleException {
103113
assertThat(new Alphametics("AND + A + STRONG + OFFENSE + AS + A + GOOD == DEFENSE").solve())
104114
.containsOnly(
@@ -116,7 +126,8 @@ public void testTenLetters() throws UnsolvablePuzzleException {
116126

117127
@Disabled("Remove to run test")
118128
@Test
119-
public void testTenLetters41Addends() throws UnsolvablePuzzleException {
129+
@DisplayName("puzzle with ten letters and 199 addends")
130+
public void testTenLetters199Addends() throws UnsolvablePuzzleException {
120131
assertThat(new Alphametics("THIS + A + FIRE + THEREFORE + FOR + ALL + HISTORIES + I + TELL + A + " +
121132
"TALE + THAT + FALSIFIES + ITS + TITLE + TIS + A + LIE + THE + TALE + OF + THE + LAST + FIRE + " +
122133
"HORSES + LATE + AFTER + THE + FIRST + FATHERS + FORESEE + THE + HORRORS + THE + LAST + FREE + " +

exercises/practice/anagram/src/test/java/AnagramTest.java

Lines changed: 19 additions & 0 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 java.util.Arrays;
@@ -9,6 +10,7 @@
910
public class AnagramTest {
1011

1112
@Test
13+
@DisplayName("no matches")
1214
public void testNoMatches() {
1315
Anagram detector = new Anagram("diaper");
1416

@@ -20,6 +22,7 @@ public void testNoMatches() {
2022

2123
@Disabled("Remove to run test")
2224
@Test
25+
@DisplayName("detects two anagrams")
2326
public void testDetectsTwoAnagrams() {
2427
Anagram detector = new Anagram("solemn");
2528

@@ -29,6 +32,7 @@ public void testDetectsTwoAnagrams() {
2932

3033
@Disabled("Remove to run test")
3134
@Test
35+
@DisplayName("does not detect anagram subsets")
3236
public void testEliminateAnagramSubsets() {
3337
Anagram detector = new Anagram("good");
3438

@@ -37,6 +41,7 @@ public void testEliminateAnagramSubsets() {
3741

3842
@Disabled("Remove to run test")
3943
@Test
44+
@DisplayName("detects anagram")
4045
public void testDetectLongerAnagram() {
4146
Anagram detector = new Anagram("listen");
4247

@@ -48,6 +53,7 @@ public void testDetectLongerAnagram() {
4853

4954
@Disabled("Remove to run test")
5055
@Test
56+
@DisplayName("detects three anagrams")
5157
public void testDetectMultipleAnagramsForLongerWord() {
5258
Anagram detector = new Anagram("allergy");
5359
assertThat(
@@ -64,6 +70,7 @@ public void testDetectMultipleAnagramsForLongerWord() {
6470

6571
@Disabled("Remove to run test")
6672
@Test
73+
@DisplayName("detects multiple anagrams with different case")
6774
public void testDetectsMultipleAnagramsWithDifferentCase() {
6875
Anagram detector = new Anagram("nose");
6976

@@ -73,6 +80,7 @@ public void testDetectsMultipleAnagramsWithDifferentCase() {
7380

7481
@Disabled("Remove to run test")
7582
@Test
83+
@DisplayName("does not detect non-anagrams with identical checksum")
7684
public void testEliminateAnagramsWithSameChecksum() {
7785
Anagram detector = new Anagram("mass");
7886

@@ -82,6 +90,7 @@ public void testEliminateAnagramsWithSameChecksum() {
8290

8391
@Disabled("Remove to run test")
8492
@Test
93+
@DisplayName("detects anagrams case-insensitively")
8594
public void testCaseInsensitiveWhenBothAnagramAndSubjectStartWithUpperCaseLetter() {
8695
Anagram detector = new Anagram("Orchestra");
8796

@@ -93,6 +102,7 @@ public void testCaseInsensitiveWhenBothAnagramAndSubjectStartWithUpperCaseLetter
93102

94103
@Disabled("Remove to run test")
95104
@Test
105+
@DisplayName("detects anagrams using case-insensitive subject")
96106
public void testCaseInsensitiveWhenSubjectStartsWithUpperCaseLetter() {
97107
Anagram detector = new Anagram("Orchestra");
98108

@@ -104,6 +114,7 @@ public void testCaseInsensitiveWhenSubjectStartsWithUpperCaseLetter() {
104114

105115
@Disabled("Remove to run test")
106116
@Test
117+
@DisplayName("detects anagrams using case-insensitive possible matches")
107118
public void testCaseInsensitiveWhenAnagramStartsWithUpperCaseLetter() {
108119
Anagram detector = new Anagram("orchestra");
109120

@@ -115,6 +126,7 @@ public void testCaseInsensitiveWhenAnagramStartsWithUpperCaseLetter() {
115126

116127
@Disabled("Remove to run test")
117128
@Test
129+
@DisplayName("does not detect an anagram if the original word is repeated")
118130
public void testIdenticalWordRepeatedIsNotAnagram() {
119131
Anagram detector = new Anagram("go");
120132

@@ -124,6 +136,7 @@ public void testIdenticalWordRepeatedIsNotAnagram() {
124136

125137
@Disabled("Remove to run test")
126138
@Test
139+
@DisplayName("anagrams must use all letters exactly once")
127140
public void testAnagramMustUseAllLettersExactlyOnce() {
128141
Anagram detector = new Anagram("tapper");
129142

@@ -133,6 +146,7 @@ public void testAnagramMustUseAllLettersExactlyOnce() {
133146

134147
@Disabled("Remove to run test")
135148
@Test
149+
@DisplayName("words are not anagrams of themselves")
136150
public void testWordsAreNotAnagramsOfThemselvesCaseInsensitive() {
137151
Anagram detector = new Anagram("BANANA");
138152

@@ -142,6 +156,7 @@ public void testWordsAreNotAnagramsOfThemselvesCaseInsensitive() {
142156

143157
@Disabled("Remove to run test")
144158
@Test
159+
@DisplayName("words are not anagrams of themselves even if letter case is partially different")
145160
public void testWordsAreNotAnagramsOfThemselvesEvenIfLetterCaseIsPartiallyDifferent() {
146161
Anagram detector = new Anagram("BANANA");
147162

@@ -151,6 +166,7 @@ public void testWordsAreNotAnagramsOfThemselvesEvenIfLetterCaseIsPartiallyDiffer
151166

152167
@Disabled("Remove to run test")
153168
@Test
169+
@DisplayName("words are not anagrams of themselves even if letter case is completely different")
154170
public void testWordsAreNotAnagramsOfThemselvesEvenIfLetterCaseIsCompletelyDifferent() {
155171
Anagram detector = new Anagram("BANANA");
156172

@@ -160,6 +176,7 @@ public void testWordsAreNotAnagramsOfThemselvesEvenIfLetterCaseIsCompletelyDiffe
160176

161177
@Disabled("Remove to run test")
162178
@Test
179+
@DisplayName("words other than themselves can be anagrams")
163180
public void testWordsOtherThanThemselvesCanBeAnagrams() {
164181
Anagram detector = new Anagram("LISTEN");
165182

@@ -169,6 +186,7 @@ public void testWordsOtherThanThemselvesCanBeAnagrams() {
169186

170187
@Disabled("Remove to run test")
171188
@Test
189+
@DisplayName("handles case of greek letters")
172190
public void testHandlesCaseOfGreekLetters() {
173191
Anagram detector = new Anagram("ΑΒΓ");
174192

@@ -178,6 +196,7 @@ public void testHandlesCaseOfGreekLetters() {
178196

179197
@Disabled("Remove to run test")
180198
@Test
199+
@DisplayName("different characters may have the same bytes")
181200
public void testDifferentCharactersWithSameBytes() {
182201
Anagram detector = new Anagram("a⬂");
183202

exercises/practice/armstrong-numbers/src/test/java/ArmstrongNumbersTest.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import org.junit.jupiter.api.BeforeEach;
22
import org.junit.jupiter.api.Disabled;
3+
import org.junit.jupiter.api.DisplayName;
34
import org.junit.jupiter.api.Test;
45

56
import static org.assertj.core.api.Assertions.assertThat;
@@ -14,62 +15,71 @@ public void setup() {
1415
}
1516

1617
@Test
18+
@DisplayName("Zero is an Armstrong number")
1719
public void zeroIsArmstrongNumber() {
1820
assertThat(armstrongNumbers.isArmstrongNumber(0))
1921
.isTrue();
2022
}
2123

2224
@Disabled("Remove to run test")
2325
@Test
26+
@DisplayName("Single-digit numbers are Armstrong numbers")
2427
public void singleDigitsAreArmstrongNumbers() {
2528
assertThat(armstrongNumbers.isArmstrongNumber(5))
2629
.isTrue();
2730
}
2831

2932
@Disabled("Remove to run test")
3033
@Test
34+
@DisplayName("There are no two-digit Armstrong numbers")
3135
public void noTwoDigitArmstrongNumbers() {
3236
assertThat(armstrongNumbers.isArmstrongNumber(10))
3337
.isFalse();
3438
}
3539

3640
@Disabled("Remove to run test")
3741
@Test
42+
@DisplayName("Three-digit number that is an Armstrong number")
3843
public void threeDigitNumberIsArmstrongNumber() {
3944
assertThat(armstrongNumbers.isArmstrongNumber(153))
4045
.isTrue();
4146
}
4247

4348
@Disabled("Remove to run test")
4449
@Test
50+
@DisplayName("Three-digit number that is not an Armstrong number")
4551
public void threeDigitNumberIsNotArmstrongNumber() {
4652
assertThat(armstrongNumbers.isArmstrongNumber(100))
4753
.isFalse();
4854
}
4955

5056
@Disabled("Remove to run test")
5157
@Test
58+
@DisplayName("Four-digit number that is an Armstrong number")
5259
public void fourDigitNumberIsArmstrongNumber() {
5360
assertThat(armstrongNumbers.isArmstrongNumber(9474))
5461
.isTrue();
5562
}
5663

5764
@Disabled("Remove to run test")
5865
@Test
66+
@DisplayName("Four-digit number that is not an Armstrong number")
5967
public void fourDigitNumberIsNotArmstrongNumber() {
6068
assertThat(armstrongNumbers.isArmstrongNumber(9475))
6169
.isFalse();
6270
}
6371

6472
@Disabled("Remove to run test")
6573
@Test
74+
@DisplayName("Seven-digit number that is an Armstrong number")
6675
public void sevenDigitNumberIsArmstrongNumber() {
6776
assertThat(armstrongNumbers.isArmstrongNumber(9926315))
6877
.isTrue();
6978
}
7079

7180
@Disabled("Remove to run test")
7281
@Test
82+
@DisplayName("Seven-digit number that is not an Armstrong number")
7383
public void sevenDigitNumberIsNotArmstrongNumber() {
7484
assertThat(armstrongNumbers.isArmstrongNumber(9926314))
7585
.isFalse();

0 commit comments

Comments
 (0)