Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
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 @@ -8,57 +9,65 @@ public class AffineCipherTest {

private AffineCipher affineCipher = new AffineCipher();

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

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


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

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

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

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

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

@DisplayName("encode all the letters")
@Disabled("Remove to run test")
@Test
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");
}

@DisplayName("encode with a not coprime to m")
@Disabled("Remove to run test")
@Test
public void testEncodeThrowsMeaningfulException() {
Expand All @@ -67,48 +76,55 @@ public void testEncodeThrowsMeaningfulException() {
.withMessage("Error: keyA and alphabet size must be coprime.");
}

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

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

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

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

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

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

@DisplayName("decode with a not coprime to m")
@Disabled("Remove to run test")
@Test
public void testDecodeThrowsMeaningfulException() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
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;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;

public class BaseConverterTest {

@DisplayName("single bit one to decimal")
@Test
public void testSingleBitOneToDecimal() {
BaseConverter baseConverter = new BaseConverter(2, new int[]{1});
Expand All @@ -14,6 +16,7 @@ public void testSingleBitOneToDecimal() {
.containsExactly(1);
}

@DisplayName("binary to single decimal")
@Disabled("Remove to run test")
@Test
public void testBinaryToSingleDecimal() {
Expand All @@ -23,6 +26,7 @@ public void testBinaryToSingleDecimal() {
.containsExactly(5);
}

@DisplayName("single decimal to binary")
@Disabled("Remove to run test")
@Test
public void testSingleDecimalToBinary() {
Expand All @@ -32,6 +36,7 @@ public void testSingleDecimalToBinary() {
.containsExactly(1, 0, 1);
}

@DisplayName("binary to multiple decimal")
@Disabled("Remove to run test")
@Test
public void testBinaryToMultipleDecimal() {
Expand All @@ -41,6 +46,7 @@ public void testBinaryToMultipleDecimal() {
.containsExactly(4, 2);
}

@DisplayName("decimal to binary")
@Disabled("Remove to run test")
@Test
public void testDecimalToBinary() {
Expand All @@ -50,6 +56,7 @@ public void testDecimalToBinary() {
.containsExactly(1, 0, 1, 0, 1, 0);
}

@DisplayName("trinary to hexadecimal")
@Disabled("Remove to run test")
@Test
public void testTrinaryToHexadecimal() {
Expand All @@ -59,6 +66,7 @@ public void testTrinaryToHexadecimal() {
.containsExactly(2, 10);
}

@DisplayName("hexadecimal to trinary")
@Disabled("Remove to run test")
@Test
public void testHexadecimalToTrinary() {
Expand All @@ -68,6 +76,7 @@ public void testHexadecimalToTrinary() {
.containsExactly(1, 1, 2, 0);
}

@DisplayName("15-bit integer")
@Disabled("Remove to run test")
@Test
public void test15BitInteger() {
Expand All @@ -77,6 +86,7 @@ public void test15BitInteger() {
.containsExactly(6, 10, 45);
}

@DisplayName("empty list")
@Disabled("Remove to run test")
@Test
public void testEmptyDigits() {
Expand All @@ -86,6 +96,7 @@ public void testEmptyDigits() {
.containsExactly(0);
}

@DisplayName("single zero")
@Disabled("Remove to run test")
@Test
public void testSingleZero() {
Expand All @@ -95,6 +106,7 @@ public void testSingleZero() {
.containsExactly(0);
}

@DisplayName("multiple zeros")
@Disabled("Remove to run test")
@Test
public void testMultipleZeros() {
Expand All @@ -104,6 +116,7 @@ public void testMultipleZeros() {
.containsExactly(0);
}

@DisplayName("leading zeros")
@Disabled("Remove to run test")
@Test
public void testLeadingZeros() {
Expand All @@ -113,22 +126,25 @@ public void testLeadingZeros() {
.containsExactly(4, 2);
}

@DisplayName("input base is one")
@Disabled("Remove to run test")
@Test
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.");
}

@DisplayName("input base is zero")
@Disabled("Remove to run test")
@Test
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.");
}

@DisplayName("input base is negative")
@Disabled("Remove to run test")
@Test
public void testFirstBaseIsNegative() {
Expand All @@ -137,6 +153,7 @@ public void testFirstBaseIsNegative() {
.withMessage("Bases must be at least 2.");
}

@DisplayName("negative digit")
@Disabled("Remove to run test")
@Test
public void testNegativeDigit() {
Expand All @@ -145,6 +162,7 @@ public void testNegativeDigit() {
.withMessage("Digits may not be negative.");
}

@DisplayName("invalid positive digit")
@Disabled("Remove to run test")
@Test
public void testInvalidPositiveDigit() {
Expand All @@ -153,6 +171,7 @@ public void testInvalidPositiveDigit() {
.withMessage("All digits must be strictly less than the base.");
}

@DisplayName("output base is one")
@Disabled("Remove to run test")
@Test
public void testSecondBaseIsOne() {
Expand All @@ -164,6 +183,7 @@ public void testSecondBaseIsOne() {
.withMessage("Bases must be at least 2.");
}

@DisplayName("output base is zero")
@Disabled("Remove to run test")
@Test
public void testSecondBaseIsZero() {
Expand All @@ -174,6 +194,7 @@ public void testSecondBaseIsZero() {
.withMessage("Bases must be at least 2.");
}

@DisplayName("output base is negative")
@Disabled("Remove to run test")
@Test
public void testSecondBaseIsNegative() {
Expand Down
Loading