Skip to content
Open
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,4 +1,5 @@
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

import java.util.List;
Expand All @@ -10,6 +11,7 @@
public class RelationshipComputerTest {

@Test
@DisplayName("empty lists")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this exercise, the order of the tests doesn’t align perfectly with the canonical data file, especially towards the end. Could you also fix the order of the tests to match the canonical data file? Also, I believe there are no extra or missing tests, but let me know if you find any

public void testThatTwoEmptyListsAreConsideredEqual() {
Relationship relationship = new RelationshipComputer<>().computeRelationship(
emptyList(),
Expand All @@ -20,6 +22,7 @@ public void testThatTwoEmptyListsAreConsideredEqual() {

@Disabled("Remove to run test")
@Test
@DisplayName("empty list within non empty list")
public void testEmptyListIsSublistOfNonEmptyList() {
Relationship relationship = new RelationshipComputer<>().computeRelationship(
emptyList(),
Expand All @@ -30,6 +33,7 @@ public void testEmptyListIsSublistOfNonEmptyList() {

@Disabled("Remove to run test")
@Test
@DisplayName("non empty list contains empty list")
public void testNonEmptyListIsSuperlistOfEmptyList() {
Relationship relationship = new RelationshipComputer<>().computeRelationship(
asList('1', '2', '3'),
Expand All @@ -40,6 +44,7 @@ public void testNonEmptyListIsSuperlistOfEmptyList() {

@Disabled("Remove to run test")
@Test
@DisplayName("list equals itself")
public void testListIsEqualToItself() {
List<String> anyList = asList("1", "2", "3");

Expand All @@ -52,6 +57,7 @@ public void testListIsEqualToItself() {

@Disabled("Remove to run test")
@Test
@DisplayName("different lists")
public void testDifferentListsOfTheSameLengthAreUnequal() {
Relationship relationship = new RelationshipComputer<>().computeRelationship(
asList(1, 2, 3),
Expand All @@ -62,6 +68,7 @@ public void testDifferentListsOfTheSameLengthAreUnequal() {

@Disabled("Remove to run test")
@Test
@DisplayName("false start")
public void testSublistCheckDoesNotAbortAfterFalseStart() {
Relationship relationship = new RelationshipComputer<>().computeRelationship(
asList('1', '2', '5'),
Expand All @@ -72,6 +79,7 @@ public void testSublistCheckDoesNotAbortAfterFalseStart() {

@Disabled("Remove to run test")
@Test
@DisplayName("consecutive")
public void testSublistCheckHandlesExtraneousRepeatsOfFirstEntry() {
Relationship relationship = new RelationshipComputer<>().computeRelationship(
asList("1", "1", "2"),
Expand All @@ -82,6 +90,7 @@ public void testSublistCheckHandlesExtraneousRepeatsOfFirstEntry() {

@Disabled("Remove to run test")
@Test
@DisplayName("sublist at start")
public void testSublistAtStart() {
Relationship relationship = new RelationshipComputer<>().computeRelationship(
asList(0, 1, 2),
Expand All @@ -92,6 +101,7 @@ public void testSublistAtStart() {

@Disabled("Remove to run test")
@Test
@DisplayName("sublist in middle")
public void testSublistInMiddle() {
Relationship relationship = new RelationshipComputer<>().computeRelationship(
asList('2', '3', '4'),
Expand All @@ -102,6 +112,7 @@ public void testSublistInMiddle() {

@Disabled("Remove to run test")
@Test
@DisplayName("sublist at end")
public void testSublistAtEnd() {
Relationship relationship = new RelationshipComputer<>().computeRelationship(
asList("3", "4", "5"),
Expand All @@ -112,6 +123,7 @@ public void testSublistAtEnd() {

@Disabled("Remove to run test")
@Test
@DisplayName("at start of superlist")
public void testAtStartOfSuperlist() {
Relationship relationship = new RelationshipComputer<>().computeRelationship(
asList(0, 1, 2, 3, 4, 5),
Expand All @@ -122,6 +134,7 @@ public void testAtStartOfSuperlist() {

@Disabled("Remove to run test")
@Test
@DisplayName("in middle of superlist")
public void testInMiddleOfSuperlist() {
Relationship relationship = new RelationshipComputer<>().computeRelationship(
asList('0', '1', '2', '3', '4', '5'),
Expand All @@ -132,6 +145,7 @@ public void testInMiddleOfSuperlist() {

@Disabled("Remove to run test")
@Test
@DisplayName("at end of superlist")
public void testAtEndOfSuperlist() {
Relationship relationship = new RelationshipComputer<>().computeRelationship(
asList("0", "1", "2", "3", "4", "5"),
Expand All @@ -142,6 +156,7 @@ public void testAtEndOfSuperlist() {

@Disabled("Remove to run test")
@Test
@DisplayName("first list missing element from second list")
public void testFirstListMissingElementFromSecondList() {
Relationship relationship = new RelationshipComputer<>().computeRelationship(
asList(1, 3),
Expand All @@ -152,6 +167,7 @@ public void testFirstListMissingElementFromSecondList() {

@Disabled("Remove to run test")
@Test
@DisplayName("second list missing element from first list")
public void testSecondListMissingElementFromFirstList() {
Relationship relationship = new RelationshipComputer<>().computeRelationship(
asList('1', '2', '3'),
Expand All @@ -162,6 +178,7 @@ public void testSecondListMissingElementFromFirstList() {

@Disabled("Remove to run test")
@Test
@DisplayName("order matters to a list")
public void testThatListOrderingIsAccountedFor() {
Relationship relationship = new RelationshipComputer<>().computeRelationship(
asList("1", "2", "3"),
Expand All @@ -172,6 +189,7 @@ public void testThatListOrderingIsAccountedFor() {

@Disabled("Remove to run test")
@Test
@DisplayName("same digits but different numbers")
public void testThatListsWithSameDigitsButDifferentNumbersAreUnequal() {
Relationship relationship = new RelationshipComputer<>().computeRelationship(
asList(1, 0, 1),
Expand All @@ -182,6 +200,7 @@ public void testThatListsWithSameDigitsButDifferentNumbersAreUnequal() {

@Disabled("Remove to run test")
@Test
@DisplayName("first list missing additional digits from second list")
public void testFirstListMissingAdditionalDigitsFromSecondList() {
Relationship relationship = new RelationshipComputer<>().computeRelationship(
asList(1, 2),
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;

public class SumOfMultiplesTest {

@Test
@DisplayName("no multiples within limit")
public void testNoMultiplesWithinLimit() {

int[] set = {
Expand All @@ -19,6 +21,7 @@ public void testNoMultiplesWithinLimit() {

@Disabled("Remove to run test")
@Test
@DisplayName("one factor has multiples within limit")
public void testOneFactorHasMultiplesWithinLimit() {

int[] set = {
Expand All @@ -32,6 +35,7 @@ public void testOneFactorHasMultiplesWithinLimit() {

@Disabled("Remove to run test")
@Test
@DisplayName("more than one multiple within limit")
public void testMoreThanOneMultipleWithinLimit() {

int[] set = {
Expand All @@ -44,6 +48,7 @@ public void testMoreThanOneMultipleWithinLimit() {

@Disabled("Remove to run test")
@Test
@DisplayName("more than one factor with multiples within limit")
public void testMoreThanOneFactorWithMultiplesWithinLimit() {

int[] set = {
Expand All @@ -57,6 +62,7 @@ public void testMoreThanOneFactorWithMultiplesWithinLimit() {

@Disabled("Remove to run test")
@Test
@DisplayName("each multiple is only counted once")
public void testEachMultipleIsOnlyCountedOnce() {

int[] set = {
Expand All @@ -70,6 +76,7 @@ public void testEachMultipleIsOnlyCountedOnce() {

@Disabled("Remove to run test")
@Test
@DisplayName("a much larger limit")
public void testAMuchLargerLimit() {

int[] set = {
Expand All @@ -83,6 +90,7 @@ public void testAMuchLargerLimit() {

@Disabled("Remove to run test")
@Test
@DisplayName("three factors")
public void testThreeFactors() {

int[] set = {
Expand All @@ -97,6 +105,7 @@ public void testThreeFactors() {

@Disabled("Remove to run test")
@Test
@DisplayName("factors not relatively prime")
public void testFactorsNotRelativelyPrime() {

int[] set = {
Expand All @@ -110,6 +119,7 @@ public void testFactorsNotRelativelyPrime() {

@Disabled("Remove to run test")
@Test
@DisplayName("some pairs of factors relatively prime and some not")
public void testSomePairsOfFactorsRelativelyPrimeAndSomeNot() {

int[] set = {
Expand All @@ -124,6 +134,7 @@ public void testSomePairsOfFactorsRelativelyPrimeAndSomeNot() {

@Disabled("Remove to run test")
@Test
@DisplayName("one factor is a multiple of another")
public void testOneFactorIsAMultipleOfAnother() {

int[] set = {
Expand All @@ -137,6 +148,7 @@ public void testOneFactorIsAMultipleOfAnother() {

@Disabled("Remove to run test")
@Test
@DisplayName("much larger factors")
public void testMuchLargerFactors() {

int[] set = {
Expand All @@ -150,6 +162,7 @@ public void testMuchLargerFactors() {

@Disabled("Remove to run test")
@Test
@DisplayName("all numbers are multiples of 1")
public void testAllNumbersAreMultiplesOf1() {

int[] set = {
Expand All @@ -162,6 +175,7 @@ public void testAllNumbersAreMultiplesOf1() {

@Disabled("Remove to run test")
@Test
@DisplayName("no factors means an empty sum")
public void testNoFactorsMeanAnEmptySum() {

int[] set = {};
Expand All @@ -172,6 +186,7 @@ public void testNoFactorsMeanAnEmptySum() {

@Disabled("Remove to run test")
@Test
@DisplayName("the only multiple of 0 is 0")
public void testSumOfMultiplesOfZeroIsZero() {

int[] set = {
Expand All @@ -184,6 +199,7 @@ public void testSumOfMultiplesOfZeroIsZero() {

@Disabled("Remove to run test")
@Test
@DisplayName("the factor 0 does not affect the sum of multiples of other factors")
public void testFactorZeroDoesNotAffectTheSumOfMultiplesOfOtherFactors() {

int[] set = {
Expand All @@ -197,6 +213,7 @@ public void testFactorZeroDoesNotAffectTheSumOfMultiplesOfOtherFactors() {

@Disabled("Remove to run test")
@Test
@DisplayName("solutions using include-exclude must extend to cardinality greater than 3")
public void testSolutionsUsingIncludeExcludeMustExtendToCardinalityGreater3() {

int[] set = {
Expand Down
4 changes: 4 additions & 0 deletions exercises/practice/two-fer/src/test/java/TwoferTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import org.junit.jupiter.api.BeforeEach;
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 @@ -14,20 +15,23 @@ public void setup() {
}

@Test
@DisplayName("no name given")
public void noNameGiven() {
assertThat(twofer.twofer(null))
.isEqualTo("One for you, one for me.");
}

@Disabled("Remove to run test")
@Test
@DisplayName("a name given")
public void aNameGiven() {
assertThat(twofer.twofer("Alice"))
.isEqualTo("One for Alice, one for me.");
}

@Disabled("Remove to run test")
@Test
@DisplayName("another name given")
public void anotherNameGiven() {
assertThat(twofer.twofer("Bob"))
.isEqualTo("One for Bob, one for me.");
Expand Down
Loading