Skip to content

Commit 9dcf9a2

Browse files
FridaTveitjtigger
authored andcommitted
Issue exercism#166: Added format string to @parameters annotation in Scrabble… (exercism#222)
* Added format string to @parameters annotation in and (to make them more descriptive) changed names of variables and tests in: * AtbashTest, * BinaryTest, * OctalTest, * PigLatinTest, * RaindropsTest, * RomanNumeralsTest, * ScrabbleScoreTest. * Removed repeated word in format string for PiglatinTest and ScrabbleScoreTest. Fixes exercism#160. Fixes exercism#161. Fixes exercism#162. Fixes exercism#163. Fixes exercism#164. Fixes exercism#165. Fixes exercism#166.
1 parent 605340a commit 9dcf9a2

7 files changed

Lines changed: 53 additions & 53 deletions

File tree

‎exercises/atbash-cipher/src/test/java/AtbashTest.java‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ public class AtbashTest {
1515

1616
@RunWith(Parameterized.class)
1717
public static class EncodeTest {
18-
private String input;
19-
private String expectedOutput;
18+
private String plaintext;
19+
private String ciphertext;
2020

21-
@Parameters
21+
@Parameters(name = "{index}: expected plaintext \"{0}\" to encode to ciphertext \"{1}\".")
2222
public static Collection<Object[]> data() {
2323
return Arrays.asList(new Object[][] {
2424
{ "no", "ml" },
@@ -31,15 +31,15 @@ public static Collection<Object[]> data() {
3131
});
3232
}
3333

34-
public EncodeTest(String input, String expectedOutput) {
35-
this.input = input;
36-
this.expectedOutput = expectedOutput;
34+
public EncodeTest(String plaintext, String ciphertext) {
35+
this.plaintext = plaintext;
36+
this.ciphertext = ciphertext;
3737
}
3838

3939

4040
@Test
4141
public void test() {
42-
assertEquals(expectedOutput, Atbash.encode(input));
42+
assertEquals(ciphertext, Atbash.encode(plaintext));
4343
}
4444
}
4545

‎exercises/binary/src/test/java/BinaryTest.java‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
@RunWith(Parameterized.class)
1313
public class BinaryTest {
1414

15-
private String input;
16-
private int expectedOutput;
15+
private String binaryNumberAsString;
16+
private int decimalNumber;
1717

18-
@Parameters
18+
@Parameters(name = "{index}: expected {1} when converting \"{0}\" from binary to decimal.")
1919
public static Collection<Object[]> data() {
2020
return Arrays.asList(new Object[][]{
2121
{"1", 1},
@@ -34,16 +34,16 @@ public static Collection<Object[]> data() {
3434
});
3535
}
3636

37-
public BinaryTest(String input, int expectedOutput) {
38-
this.input = input;
39-
this.expectedOutput = expectedOutput;
37+
public BinaryTest(String binaryNumberAsString, int decimalNumber) {
38+
this.binaryNumberAsString = binaryNumberAsString;
39+
this.decimalNumber = decimalNumber;
4040
}
4141

4242

4343
@Test
4444
public void test() {
45-
Binary binary = new Binary(input);
45+
Binary binary = new Binary(binaryNumberAsString);
4646

47-
assertEquals(expectedOutput, binary.getDecimal());
47+
assertEquals(decimalNumber, binary.getDecimal());
4848
}
4949
}

‎exercises/octal/src/test/java/OctalTest.java‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
@RunWith(Parameterized.class)
1212
public class OctalTest {
1313

14-
private String input;
15-
private int expectedOutput;
14+
private String octalNumberAsString;
15+
private int decimalNumber;
1616

17-
@Parameterized.Parameters
17+
@Parameterized.Parameters(name = "{index}: expected {1} when converting \"{0}\" from octal to decimal.")
1818
public static Collection<Object[]> data() {
1919
return Arrays.asList(new Object[][]{
2020
{"1", 1},
@@ -34,16 +34,16 @@ public static Collection<Object[]> data() {
3434
});
3535
}
3636

37-
public OctalTest(String input, int expectedOutput) {
38-
this.input = input;
39-
this.expectedOutput = expectedOutput;
37+
public OctalTest(String octalNumberAsString, int decimalNumber) {
38+
this.octalNumberAsString = octalNumberAsString;
39+
this.decimalNumber = decimalNumber;
4040
}
4141

4242

4343
@Test
4444
public void test() {
45-
Octal octal = new Octal(input);
45+
Octal octal = new Octal(octalNumberAsString);
4646

47-
assertEquals(expectedOutput, octal.getDecimal());
47+
assertEquals(decimalNumber, octal.getDecimal());
4848
}
4949
}

‎exercises/pig-latin/src/test/java/PigLatinTest.java‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
@RunWith(Parameterized.class)
1212
public class PigLatinTest {
1313

14-
private String input;
15-
private String expectedOutput;
14+
private String englishPhrase;
15+
private String pigLatinTranslation;
1616

17-
@Parameterized.Parameters
17+
@Parameterized.Parameters(name = "{index}: expected \"{0}\" to translate to the pig latin phrase \"{1}\"")
1818
public static Collection<Object[]> data() {
1919
return Arrays.asList(new Object[][]{
2020
// Ay is added to words that start with vowels
@@ -59,14 +59,14 @@ public static Collection<Object[]> data() {
5959
});
6060
}
6161

62-
public PigLatinTest(String input, String expectedOutput) {
63-
this.input = input;
64-
this.expectedOutput = expectedOutput;
62+
public PigLatinTest(String englishPhrase, String pigLatinTranslation) {
63+
this.englishPhrase = englishPhrase;
64+
this.pigLatinTranslation = pigLatinTranslation;
6565
}
6666

6767

6868
@Test
6969
public void test() {
70-
assertEquals(expectedOutput, PigLatin.translate(input));
70+
assertEquals(pigLatinTranslation, PigLatin.translate(englishPhrase));
7171
}
7272
}

‎exercises/raindrops/src/test/java/RaindropsTest.java‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
@RunWith(Parameterized.class)
1313
public class RaindropsTest {
1414

15-
private int input;
16-
private String expectedOutput;
15+
private int inputNumber;
16+
private String outputFromRaindropConversion;
1717

18-
@Parameters
18+
@Parameters(name = "{index}: expected input number {0} to be converted to \"{1}\"")
1919
public static Collection<Object[]> data() {
2020
return Arrays.asList(new Object[][]{
2121
// Non-primes
@@ -46,14 +46,14 @@ public static Collection<Object[]> data() {
4646
});
4747
}
4848

49-
public RaindropsTest(int input, String expectedOutput) {
50-
this.input = input;
51-
this.expectedOutput = expectedOutput;
49+
public RaindropsTest(int inputNumber, String outputFromRaindropConversion) {
50+
this.inputNumber = inputNumber;
51+
this.outputFromRaindropConversion = outputFromRaindropConversion;
5252
}
5353

5454

5555
@Test
5656
public void test() {
57-
assertEquals(expectedOutput, Raindrops.convert(input));
57+
assertEquals(outputFromRaindropConversion, Raindrops.convert(inputNumber));
5858
}
5959
}

‎exercises/roman-numerals/src/test/java/RomanNumeralsTest.java‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
@RunWith(Parameterized.class)
1313
public class RomanNumeralsTest {
1414

15-
private int input;
16-
private String expectedOutput;
15+
private int arabicNumeral;
16+
private String romanNumeral;
1717

18-
@Parameters
18+
@Parameters(name = "{index}: expected arabic numeral {0} to be converted to roman numeral \"{1}\".")
1919
public static Collection<Object[]> data() {
2020
return Arrays.asList(new Object[][]{
2121
{0, ""},
@@ -40,16 +40,16 @@ public static Collection<Object[]> data() {
4040
});
4141
}
4242

43-
public RomanNumeralsTest(int input, String expectedOutput) {
44-
this.input = input;
45-
this.expectedOutput = expectedOutput;
43+
public RomanNumeralsTest(int arabicNumeral, String romanNumeral) {
44+
this.arabicNumeral = arabicNumeral;
45+
this.romanNumeral = romanNumeral;
4646
}
4747

4848

4949
@Test
5050
public void convertArabicNumberalToRomanNumeral() {
51-
RomanNumeral romanNumeral = new RomanNumeral(input);
51+
RomanNumeral romanNumeral = new RomanNumeral(arabicNumeral);
5252

53-
assertEquals(expectedOutput, romanNumeral.getRomanNumeral());
53+
assertEquals(this.romanNumeral, romanNumeral.getRomanNumeral());
5454
}
5555
}

‎exercises/scrabble-score/src/test/java/ScrabbleScoreTest.java‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
@RunWith(Parameterized.class)
1212
public class ScrabbleScoreTest {
1313

14-
private String input;
15-
private int expectedOutput;
14+
private String scrabbleInput;
15+
private int scrabbleScore;
1616

17-
@Parameterized.Parameters
17+
@Parameterized.Parameters(name = "{index}: expected scrabble score for \"{0}\" to be {1}")
1818
public static Collection<Object[]> data() {
1919
return Arrays.asList(new Object[][]{
2020
{"", 0},
@@ -29,16 +29,16 @@ public static Collection<Object[]> data() {
2929
});
3030
}
3131

32-
public ScrabbleScoreTest(String input, int expectedOutput) {
33-
this.input = input;
34-
this.expectedOutput = expectedOutput;
32+
public ScrabbleScoreTest(String scrabbleInput, int scrabbleScore) {
33+
this.scrabbleInput = scrabbleInput;
34+
this.scrabbleScore = scrabbleScore;
3535
}
3636

3737

3838
@Test
3939
public void test() {
40-
Scrabble scrabble = new Scrabble(input);
40+
Scrabble scrabble = new Scrabble(scrabbleInput);
4141

42-
assertEquals(expectedOutput, scrabble.getScore());
42+
assertEquals(scrabbleScore, scrabble.getScore());
4343
}
4444
}

0 commit comments

Comments
 (0)