Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions exercises/practice/acronym/src/test/java/AcronymTest.java
Original file line number Diff line number Diff line change
@@ -1,78 +1,77 @@
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

import static org.assertj.core.api.Assertions.assertThat;

public class AcronymTest {


@DisplayName("basic")
@Test
@DisplayName("basic")
public void basic() {
assertThat(new Acronym("Portable Network Graphics").get())
.isEqualTo("PNG");
}

@DisplayName("lowercase words")
@Disabled("Remove to run test")
@Test
@DisplayName("lowercase words")
public void lowercaseWords() {
assertThat(new Acronym("Ruby on Rails").get())
.isEqualTo("ROR");
}

@DisplayName("punctuation")
@Disabled("Remove to run test")
@Test
@DisplayName("punctuation")
public void punctuation() {
assertThat(new Acronym("First In, First Out").get())
.isEqualTo("FIFO");
}

@DisplayName("all caps word")
@Disabled("Remove to run test")
@Test
@DisplayName("all caps word")
public void nonAcronymAllCapsWord() {
assertThat(new Acronym("GNU Image Manipulation Program").get())
.isEqualTo("GIMP");
}

@DisplayName("punctuation without whitespace")
@Disabled("Remove to run test")
@Test
@DisplayName("punctuation without whitespace")
public void punctuationWithoutWhitespace() {
assertThat(new Acronym("Complementary metal-oxide semiconductor").get())
.isEqualTo("CMOS");
}

@DisplayName("very long abbreviation")
@Disabled("Remove to run test")
@Test
@DisplayName("very long abbreviation")
public void veryLongAbbreviation() {
assertThat(new Acronym("Rolling On The Floor Laughing So Hard That My Dogs Came Over And Licked Me").get())
.isEqualTo("ROTFLSHTMDCOALM");
}

@DisplayName("consecutive delimiters")
@Disabled("Remove to run test")
@Test
@DisplayName("consecutive delimiters")
public void consecutiveDelimiters() {
assertThat(new Acronym("Something - I made up from thin air").get())
.isEqualTo("SIMUFTA");
}

@DisplayName("apostrophes")
@Disabled("Remove to run test")
@Test
@DisplayName("apostrophes")
public void apostrophes() {
assertThat(new Acronym("Halley's Comet").get())
.isEqualTo("HC");
}

@DisplayName("underscore emphasis")
@Disabled("Remove to run test")
@Test
@DisplayName("underscore emphasis")
public void underscoreEmphasis() {
assertThat(new Acronym("The Road _Not_ Taken").get())
.isEqualTo("TRNT");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

import static org.assertj.core.api.Assertions.assertThat;
Expand All @@ -9,58 +10,66 @@ public class AffineCipherTest {
private AffineCipher affineCipher = new AffineCipher();

@Test
@DisplayName("encode yes")
public void testEncodeYes() {
assertThat(affineCipher.encode("yes", 5, 7)).isEqualTo("xbt");
}

@Disabled("Remove to run test")
@Test
@DisplayName("encode no")
public void testEncodeNo() {
assertThat(affineCipher.encode("no", 15, 18)).isEqualTo("fu");
}


@Disabled("Remove to run test")
@DisplayName("encode OMG")
@Test
public void testEncodeOMG() {
assertThat(affineCipher.encode("OMG", 21, 3)).isEqualTo("lvz");
}

@Disabled("Remove to run test")
@Test
@DisplayName("encode O M G")
public void testEncodeO_M_G() {
assertThat(affineCipher.encode("O M G", 25, 47)).isEqualTo("hjp");
}

@Disabled("Remove to run test")
@Test
@DisplayName("encode mindblowingly")
public void testEncodeMindBlowingly() {
assertThat(affineCipher.encode("mindblowingly", 11, 15)).isEqualTo("rzcwa gnxzc dgt");
}

@Disabled("Remove to run test")
@Test
@DisplayName("encode numbers")
public void testEncodeNumbers() {
assertThat(affineCipher.encode("Testing,1 2 3, testing.", 3, 4))
.isEqualTo("jqgjc rw123 jqgjc rw");
}

@Disabled("Remove to run test")
@Test
@DisplayName("encode deep thought")
public void testEncodeDeepThought() {
assertThat(affineCipher.encode("Truth is fiction.", 5, 17))
.isEqualTo("iynia fdqfb ifje");
}

@Disabled("Remove to run test")
@Test
@DisplayName("encode all the letters")
public void testEncodeAllTheLetters() {
assertThat(affineCipher.encode("The quick brown fox jumps over the lazy dog.", 17, 33))
.isEqualTo("swxtj npvyk lruol iejdc blaxk swxmh qzglf");
}

@Disabled("Remove to run test")
@Test
@DisplayName("encode with a not coprime to m")
public void testEncodeThrowsMeaningfulException() {
assertThatExceptionOfType(IllegalArgumentException.class)
.isThrownBy(() -> affineCipher.encode("This is a test", 6, 17))
Expand All @@ -69,48 +78,55 @@ public void testEncodeThrowsMeaningfulException() {

@Disabled("Remove to run test")
@Test
@DisplayName("decode exercism")
public void testDecodeExercism() {
assertThat(affineCipher.decode("tytgn fjr", 3, 7))
.isEqualTo("exercism");
}

@Disabled("Remove to run test")
@Test
@DisplayName("decode a sentence")
public void testDecodeSentence() {
assertThat(affineCipher.decode("qdwju nqcro muwhn odqun oppmd aunwd o", 19, 16))
.isEqualTo("anobstacleisoftenasteppingstone");
}

@Disabled("Remove to run test")
@Test
@DisplayName("decode numbers")
public void testDecodeNumbers() {
assertThat(affineCipher.decode("odpoz ub123 odpoz ub", 25, 7))
.isEqualTo("testing123testing");
}

@Disabled("Remove to run test")
@Test
@DisplayName("decode all the letters")
public void testDecodeAllTheLetters() {
assertThat(affineCipher.decode("swxtj npvyk lruol iejdc blaxk swxmh qzglf", 17, 33))
.isEqualTo("thequickbrownfoxjumpsoverthelazydog");
}

@Disabled("Remove to run test")
@Test
@DisplayName("decode with no spaces in input")
public void testDecodeWithNoSpaces() {
assertThat(affineCipher.decode("swxtjnpvyklruoliejdcblaxkswxmhqzglf", 17, 33))
.isEqualTo("thequickbrownfoxjumpsoverthelazydog");
}

@Disabled("Remove to run test")
@Test
@DisplayName("decode with too many spaces")
public void testDecodeWithTooManySpaces() {
assertThat(affineCipher.decode("vszzm cly yd cg qdp", 15, 16))
.isEqualTo("jollygreengiant");
}

@Disabled("Remove to run test")
@Test
@DisplayName("decode with a not coprime to m")
public void testDecodeThrowsMeaningfulException() {
assertThatExceptionOfType(IllegalArgumentException.class)
.isThrownBy(() -> affineCipher.decode("Test", 13, 5))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

import static org.assertj.core.api.Assertions.assertThat;
Expand All @@ -7,6 +8,7 @@
public class BaseConverterTest {

@Test
@DisplayName("single bit one to decimal")
public void testSingleBitOneToDecimal() {
BaseConverter baseConverter = new BaseConverter(2, new int[]{1});

Expand All @@ -16,6 +18,7 @@ public void testSingleBitOneToDecimal() {

@Disabled("Remove to run test")
@Test
@DisplayName("binary to single decimal")
public void testBinaryToSingleDecimal() {
BaseConverter baseConverter = new BaseConverter(2, new int[]{1, 0, 1});

Expand All @@ -25,6 +28,7 @@ public void testBinaryToSingleDecimal() {

@Disabled("Remove to run test")
@Test
@DisplayName("single decimal to binary")
public void testSingleDecimalToBinary() {
BaseConverter baseConverter = new BaseConverter(10, new int[]{5});

Expand All @@ -34,6 +38,7 @@ public void testSingleDecimalToBinary() {

@Disabled("Remove to run test")
@Test
@DisplayName("binary to multiple decimal")
public void testBinaryToMultipleDecimal() {
BaseConverter baseConverter = new BaseConverter(2, new int[]{1, 0, 1, 0, 1, 0});

Expand All @@ -43,6 +48,7 @@ public void testBinaryToMultipleDecimal() {

@Disabled("Remove to run test")
@Test
@DisplayName("decimal to binary")
public void testDecimalToBinary() {
BaseConverter baseConverter = new BaseConverter(10, new int[]{4, 2});

Expand All @@ -52,6 +58,7 @@ public void testDecimalToBinary() {

@Disabled("Remove to run test")
@Test
@DisplayName("trinary to hexadecimal")
public void testTrinaryToHexadecimal() {
BaseConverter baseConverter = new BaseConverter(3, new int[]{1, 1, 2, 0});

Expand All @@ -61,6 +68,7 @@ public void testTrinaryToHexadecimal() {

@Disabled("Remove to run test")
@Test
@DisplayName("hexadecimal to trinary")
public void testHexadecimalToTrinary() {
BaseConverter baseConverter = new BaseConverter(16, new int[]{2, 10});

Expand All @@ -70,6 +78,7 @@ public void testHexadecimalToTrinary() {

@Disabled("Remove to run test")
@Test
@DisplayName("15-bit integer")
public void test15BitInteger() {
BaseConverter baseConverter = new BaseConverter(97, new int[]{3, 46, 60});

Expand All @@ -79,6 +88,7 @@ public void test15BitInteger() {

@Disabled("Remove to run test")
@Test
@DisplayName("empty list")
public void testEmptyDigits() {
BaseConverter baseConverter = new BaseConverter(2, new int[]{});

Expand All @@ -88,6 +98,7 @@ public void testEmptyDigits() {

@Disabled("Remove to run test")
@Test
@DisplayName("single zero")
public void testSingleZero() {
BaseConverter baseConverter = new BaseConverter(10, new int[]{0});

Expand All @@ -97,6 +108,7 @@ public void testSingleZero() {

@Disabled("Remove to run test")
@Test
@DisplayName("multiple zeros")
public void testMultipleZeros() {
BaseConverter baseConverter = new BaseConverter(10, new int[]{0, 0, 0});

Expand All @@ -106,6 +118,7 @@ public void testMultipleZeros() {

@Disabled("Remove to run test")
@Test
@DisplayName("leading zeros")
public void testLeadingZeros() {
BaseConverter baseConverter = new BaseConverter(7, new int[]{0, 6, 0});

Expand All @@ -115,22 +128,25 @@ public void testLeadingZeros() {

@Disabled("Remove to run test")
@Test
@DisplayName("input base is one")
public void testFirstBaseIsOne() {
assertThatExceptionOfType(IllegalArgumentException.class)
.isThrownBy(() -> new BaseConverter(1, new int[]{1}))
.isThrownBy(() -> new BaseConverter(1, new int[]{0}))
.withMessage("Bases must be at least 2.");
}

@Disabled("Remove to run test")
@Test
@DisplayName("input base is zero")
public void testFirstBaseIsZero() {
assertThatExceptionOfType(IllegalArgumentException.class)
.isThrownBy(() -> new BaseConverter(0, new int[]{1}))
.isThrownBy(() -> new BaseConverter(0, new int[]{}))
.withMessage("Bases must be at least 2.");
}

@Disabled("Remove to run test")
@Test
@DisplayName("input base is negative")
public void testFirstBaseIsNegative() {
assertThatExceptionOfType(IllegalArgumentException.class)
.isThrownBy(() -> new BaseConverter(-2, new int[]{1}))
Expand All @@ -139,6 +155,7 @@ public void testFirstBaseIsNegative() {

@Disabled("Remove to run test")
@Test
@DisplayName("negative digit")
public void testNegativeDigit() {
assertThatExceptionOfType(IllegalArgumentException.class)
.isThrownBy(() -> new BaseConverter(2, new int[]{1, -1, 1, 0, 1, 0}))
Expand All @@ -147,6 +164,7 @@ public void testNegativeDigit() {

@Disabled("Remove to run test")
@Test
@DisplayName("invalid positive digit")
public void testInvalidPositiveDigit() {
assertThatExceptionOfType(IllegalArgumentException.class)
.isThrownBy(() -> new BaseConverter(2, new int[]{1, 2, 1, 0, 1, 0}))
Expand All @@ -155,6 +173,7 @@ public void testInvalidPositiveDigit() {

@Disabled("Remove to run test")
@Test
@DisplayName("output base is one")
public void testSecondBaseIsOne() {
BaseConverter baseConverter =
new BaseConverter(2, new int[]{1, 0, 1, 0, 1, 0});
Expand All @@ -166,6 +185,7 @@ public void testSecondBaseIsOne() {

@Disabled("Remove to run test")
@Test
@DisplayName("output base is zero")
public void testSecondBaseIsZero() {
BaseConverter baseConverter = new BaseConverter(10, new int[]{7});

Expand All @@ -176,6 +196,7 @@ public void testSecondBaseIsZero() {

@Disabled("Remove to run test")
@Test
@DisplayName("output base is negative")
public void testSecondBaseIsNegative() {
BaseConverter baseConverter = new BaseConverter(2, new int[]{1});

Expand Down
Loading