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
Original file line number Diff line number Diff line change
@@ -1,39 +1,44 @@
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;


import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

public class PrimeCalculatorTest {

private PrimeCalculator primeCalculator = new PrimeCalculator();

@Test
@DisplayName("first prime")
public void testFirstPrime() {
assertThat(primeCalculator.nth(1)).isEqualTo(2);
}

@Disabled("Remove to run test")
@Test
@DisplayName("second prime")
public void testSecondPrime() {
assertThat(primeCalculator.nth(2)).isEqualTo(3);
}

@Disabled("Remove to run test")
@Test
@DisplayName("sixth prime")
public void testSixthPrime() {
assertThat(primeCalculator.nth(6)).isEqualTo(13);
}

@Disabled("Remove to run test")
@Test
@DisplayName("big prime")
public void testBigPrime() {
assertThat(primeCalculator.nth(10001)).isEqualTo(104743);
}

@Disabled("Remove to run test")
@Test
@DisplayName("there is no zeroth prime")
public void testUndefinedPrime() {
assertThatExceptionOfType(IllegalArgumentException.class)
.isThrownBy(() -> primeCalculator.nth(0));
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 java.util.Map;
Expand All @@ -9,6 +10,7 @@
public class NucleotideCounterTest {

@Test
@DisplayName("empty strand")
public void testEmptyDnaStringHasNoNucleotides() {
NucleotideCounter nucleotideCounter = new NucleotideCounter("");

Expand All @@ -19,6 +21,7 @@ public void testEmptyDnaStringHasNoNucleotides() {

@Disabled("Remove to run test")
@Test
@DisplayName("can count one nucleotide in single-character input")
public void testDnaStringHasOneNucleotide() {
NucleotideCounter nucleotideCounter = new NucleotideCounter("G");

Expand All @@ -29,6 +32,7 @@ public void testDnaStringHasOneNucleotide() {

@Disabled("Remove to run test")
@Test
@DisplayName("strand with repeated nucleotide")
public void testRepetitiveSequenceWithOnlyGuanine() {
NucleotideCounter nucleotideCounter = new NucleotideCounter("GGGGGGG");

Expand All @@ -39,6 +43,7 @@ public void testRepetitiveSequenceWithOnlyGuanine() {

@Disabled("Remove to run test")
@Test
@DisplayName("strand with multiple nucleotides")
public void testDnaStringHasMultipleNucleotide() {
NucleotideCounter nucleotideCounter
= new NucleotideCounter("AGCTTTTCATTCTGACTGCAACGGGCAATATGTCTCTGTGTGGATTAAAAAAAGAGTGTCTGATAGCAGC");
Expand All @@ -50,6 +55,7 @@ public void testDnaStringHasMultipleNucleotide() {

@Disabled("Remove to run test")
@Test
@DisplayName("strand with invalid nucleotides")
public void testDnaStringHasInvalidNucleotides() {
assertThatThrownBy(() -> new NucleotideCounter("AGXXACT"))
.isInstanceOf(IllegalArgumentException.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;

import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

import java.util.Arrays;

public class OpticalCharacterReaderTest {

@Test
@DisplayName("Recognizes 0")
public void testReaderRecognizesSingle0() {
String parsedInput = new OpticalCharacterReader().parse(Arrays.asList(
" _ ",
Expand All @@ -23,6 +25,7 @@ public void testReaderRecognizesSingle0() {

@Disabled("Remove to run test")
@Test
@DisplayName("Recognizes 1")
public void testReaderRecognizesSingle1() {
String parsedInput = new OpticalCharacterReader().parse(Arrays.asList(
" ",
Expand All @@ -36,6 +39,7 @@ public void testReaderRecognizesSingle1() {

@Disabled("Remove to run test")
@Test
@DisplayName("Unreadable but correctly sized inputs return ?")
public void testReaderReturnsQuestionMarkForUnreadableButCorrectlySizedInput() {
String parsedInput = new OpticalCharacterReader().parse(Arrays.asList(
" ",
Expand All @@ -49,6 +53,7 @@ public void testReaderReturnsQuestionMarkForUnreadableButCorrectlySizedInput() {

@Disabled("Remove to run test")
@Test
@DisplayName("Input with a number of lines that is not a multiple of four raises an error")
public void testReaderThrowsExceptionWhenNumberOfInputLinesIsNotAMultipleOf4() {

assertThatExceptionOfType(IllegalArgumentException.class)
Expand All @@ -63,6 +68,7 @@ public void testReaderThrowsExceptionWhenNumberOfInputLinesIsNotAMultipleOf4() {

@Disabled("Remove to run test")
@Test
@DisplayName("Input with a number of columns that is not a multiple of three raises an error")
public void testReaderThrowsExceptionWhenNumberOfInputColumnsIsNotAMultipleOf3() {


Expand All @@ -79,6 +85,7 @@ public void testReaderThrowsExceptionWhenNumberOfInputColumnsIsNotAMultipleOf3()

@Disabled("Remove to run test")
@Test
@DisplayName("Recognizes 110101100")
public void testReaderRecognizesBinarySequence110101100() {
String parsedInput = new OpticalCharacterReader().parse(Arrays.asList(
" _ _ _ _ ",
Expand All @@ -92,6 +99,7 @@ public void testReaderRecognizesBinarySequence110101100() {

@Disabled("Remove to run test")
@Test
@DisplayName("Garbled numbers in a string are replaced with ?")
public void testReaderReplacesUnreadableDigitsWithQuestionMarksWithinSequence() {
String parsedInput = new OpticalCharacterReader().parse(Arrays.asList(
" _ _ _ ",
Expand All @@ -106,6 +114,7 @@ public void testReaderReplacesUnreadableDigitsWithQuestionMarksWithinSequence()

@Disabled("Remove to run test")
@Test
@DisplayName("Recognizes 2")
public void testReaderRecognizesSingle2() {
String parsedInput = new OpticalCharacterReader().parse(Arrays.asList(
" _ ",
Expand All @@ -119,6 +128,7 @@ public void testReaderRecognizesSingle2() {

@Disabled("Remove to run test")
@Test
@DisplayName("Recognizes 3")
public void testReaderRecognizesSingle3() {
String parsedInput = new OpticalCharacterReader().parse(Arrays.asList(
" _ ",
Expand All @@ -132,6 +142,7 @@ public void testReaderRecognizesSingle3() {

@Disabled("Remove to run test")
@Test
@DisplayName("Recognizes 4")
public void testReaderRecognizesSingle4() {
String parsedInput = new OpticalCharacterReader().parse(Arrays.asList(
" ",
Expand All @@ -145,6 +156,7 @@ public void testReaderRecognizesSingle4() {

@Disabled("Remove to run test")
@Test
@DisplayName("Recognizes 5")
public void testReaderRecognizesSingle5() {
String parsedInput = new OpticalCharacterReader().parse(Arrays.asList(
" _ ",
Expand All @@ -158,6 +170,7 @@ public void testReaderRecognizesSingle5() {

@Disabled("Remove to run test")
@Test
@DisplayName("Recognizes 6")
public void testReaderRecognizesSingle6() {
String parsedInput = new OpticalCharacterReader().parse(Arrays.asList(
" _ ",
Expand All @@ -171,6 +184,7 @@ public void testReaderRecognizesSingle6() {

@Disabled("Remove to run test")
@Test
@DisplayName("Recognizes 7")
public void testReaderRecognizesSingle7() {
String parsedInput = new OpticalCharacterReader().parse(Arrays.asList(
" _ ",
Expand All @@ -184,6 +198,7 @@ public void testReaderRecognizesSingle7() {

@Disabled("Remove to run test")
@Test
@DisplayName("Recognizes 8")
public void testReaderRecognizesSingle8() {
String parsedInput = new OpticalCharacterReader().parse(Arrays.asList(
" _ ",
Expand All @@ -197,6 +212,7 @@ public void testReaderRecognizesSingle8() {

@Disabled("Remove to run test")
@Test
@DisplayName("Recognizes 9")
public void testReaderRecognizesSingle9() {
String parsedInput = new OpticalCharacterReader().parse(Arrays.asList(
" _ ",
Expand All @@ -210,6 +226,7 @@ public void testReaderRecognizesSingle9() {

@Disabled("Remove to run test")
@Test
@DisplayName("Recognizes string of decimal numbers")
public void testReaderRecognizesSequence1234567890() {
String parsedInput = new OpticalCharacterReader().parse(Arrays.asList(
" _ _ _ _ _ _ _ _ ",
Expand All @@ -223,6 +240,7 @@ public void testReaderRecognizesSequence1234567890() {

@Disabled("Remove to run test")
@Test
@DisplayName("Numbers separated by empty lines are recognized. Lines are joined by commas.")
public void testReaderRecognizesAndCorrectlyFormatsMultiRowInput() {
String parsedInput = new OpticalCharacterReader().parse(Arrays.asList(
" _ _ ",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;

import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

import java.util.Arrays;
Expand All @@ -15,6 +16,7 @@ public class PalindromeCalculatorTest {
private PalindromeCalculator palindromeCalculator = new PalindromeCalculator();

@Test
@DisplayName("find the smallest palindrome from single digit factors")
public void smallestPalindromeFromSingleDigitFactors() {
List<List<Integer>> expected = Collections.unmodifiableList(
Arrays.asList(
Expand All @@ -30,6 +32,7 @@ public void smallestPalindromeFromSingleDigitFactors() {

@Disabled("Remove to run test")
@Test
@DisplayName("find the largest palindrome from single digit factors")
public void largestPalindromeFromSingleDigitFactors() {
List<List<Integer>> expected = Collections.unmodifiableList(
Arrays.asList(
Expand All @@ -46,6 +49,7 @@ public void largestPalindromeFromSingleDigitFactors() {

@Disabled("Remove to run test")
@Test
@DisplayName("find the smallest palindrome from double digit factors")
public void largestPalindromeFromDoubleDigitFactors() {
List<List<Integer>> expected = Collections.unmodifiableList(
Arrays.asList(
Expand All @@ -62,6 +66,7 @@ public void largestPalindromeFromDoubleDigitFactors() {

@Disabled("Remove to run test")
@Test
@DisplayName("find the largest palindrome from double digit factors")
public void smallestPalindromeFromDoubleDigitFactors() {
List<List<Integer>> expected = Collections.unmodifiableList(
Arrays.asList(
Expand All @@ -78,6 +83,7 @@ public void smallestPalindromeFromDoubleDigitFactors() {

@Disabled("Remove to run test")
@Test
@DisplayName("find the largest palindrome from triple digit factors")
public void largestPalindromeFromTripleDigitFactors() {
List<List<Integer>> expected = Collections.unmodifiableList(
Arrays.asList(
Expand All @@ -94,6 +100,7 @@ public void largestPalindromeFromTripleDigitFactors() {

@Disabled("Remove to run test")
@Test
@DisplayName("find the smallest palindrome from triple digit factors")
public void smallestPalindromeFromTripleDigitFactors() {
List<List<Integer>> expected = Collections.unmodifiableList(
Arrays.asList(
Expand All @@ -110,6 +117,7 @@ public void smallestPalindromeFromTripleDigitFactors() {

@Disabled("Remove to run test")
@Test
@DisplayName("find the smallest palindrome from four digit factors")
public void smallestPalindromeFromQuadDigitFactors() {
List<List<Integer>> expected = Collections.unmodifiableList(
Arrays.asList(
Expand All @@ -126,6 +134,7 @@ public void smallestPalindromeFromQuadDigitFactors() {

@Disabled("Remove to run test")
@Test
@DisplayName("find the largest palindrome from four digit factors")
public void largestPalindromeFromQuadDigitFactors() {
List<List<Integer>> expected = Collections.unmodifiableList(
Arrays.asList(
Expand All @@ -142,6 +151,7 @@ public void largestPalindromeFromQuadDigitFactors() {

@Disabled("Remove to run test")
@Test
@DisplayName("empty result for smallest if no palindrome in the range")
public void emtpyResultSmallestNoPalindromeInRange() {

SortedMap<Long, List<List<Integer>>> palindromes = palindromeCalculator.getPalindromeProductsWithFactors(1002,
Expand All @@ -151,6 +161,7 @@ public void emtpyResultSmallestNoPalindromeInRange() {

@Disabled("Remove to run test")
@Test
@DisplayName("empty result for largest if no palindrome in the range")
public void emptyResultLargestNoPalindromeInRange() {

SortedMap<Long, List<List<Integer>>> palindromes = palindromeCalculator.getPalindromeProductsWithFactors(15,
Expand All @@ -160,6 +171,7 @@ public void emptyResultLargestNoPalindromeInRange() {

@Disabled("Remove to run test")
@Test
@DisplayName("error result for smallest if min is more than max")
public void errorSmallestMinIsMoreThanMax() {

assertThatExceptionOfType(IllegalArgumentException.class)
Expand All @@ -169,6 +181,7 @@ public void errorSmallestMinIsMoreThanMax() {

@Disabled("Remove to run test")
@Test
@DisplayName("error result for largest if min is more than max")
public void errorLargestMinIsMoreThanMax() {

assertThatExceptionOfType(IllegalArgumentException.class)
Expand All @@ -178,6 +191,7 @@ public void errorLargestMinIsMoreThanMax() {

@Disabled("Remove to run test")
@Test
@DisplayName("smallest product does not use the smallest factor")
public void smallestProductDoesNotUseTheSmallestFactor() {
List<List<Integer>> expected = Collections.unmodifiableList(
Arrays.asList(
Expand Down