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

import java.time.LocalDate;
Expand All @@ -10,6 +11,7 @@
public class GigasecondTest {

@Test
@DisplayName("date only specification of time")
public void modernTime() {
Gigasecond gigaSecond = new Gigasecond(LocalDate.of(2011, Month.APRIL, 25));

Expand All @@ -18,6 +20,7 @@ public void modernTime() {

@Disabled("Remove to run test")
@Test
@DisplayName("second test for date only specification of time")
public void afterEpochTime() {
Gigasecond gigaSecond = new Gigasecond(LocalDate.of(1977, Month.JUNE, 13));

Expand All @@ -26,6 +29,7 @@ public void afterEpochTime() {

@Disabled("Remove to run test")
@Test
@DisplayName("third test for date only specification of time")
public void beforeEpochTime() {
Gigasecond gigaSecond = new Gigasecond(LocalDate.of(1959, Month.JULY, 19));

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

@Disabled("Remove to run test")
@Test
@DisplayName("full time specified")
public void withFullTimeSpecified() {
Gigasecond gigaSecond = new Gigasecond(LocalDateTime.of(2015, Month.JANUARY, 24, 22, 0, 0));

Expand All @@ -42,6 +47,7 @@ public void withFullTimeSpecified() {

@Disabled("Remove to run test")
@Test
@DisplayName("full time with day roll-over")
public void withFullTimeSpecifiedAndDayRollover() {
Gigasecond gigaSecond = new Gigasecond(LocalDateTime.of(2015, Month.JANUARY, 24, 23, 59, 59));

Expand All @@ -50,6 +56,7 @@ public void withFullTimeSpecifiedAndDayRollover() {

@Disabled("Remove to run test")
@Test
@DisplayName("does not mutate the input")
public void doesNotMutateInput() {
LocalDateTime input = LocalDateTime.of(2015, Month.JANUARY, 24, 23, 59, 59);
new Gigasecond(input).getDateTime();
Expand Down
12 changes: 12 additions & 0 deletions exercises/practice/go-counting/src/test/java/GoCountingTest.java
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.awt.*;
Expand All @@ -18,6 +19,7 @@ public class GoCountingTest {
" W ";

@Test
@DisplayName("Black corner territory on 5x5 board")
public void blackCorner5x5BoardTest() {
GoCounting gocounting = new GoCounting(board5x5);

Expand All @@ -32,6 +34,7 @@ public void blackCorner5x5BoardTest() {

@Disabled("Remove to run test")
@Test
@DisplayName("White center territory on 5x5 board")
public void whiteCenter5x5BoardTest() {
GoCounting gocounting = new GoCounting(board5x5);

Expand All @@ -44,6 +47,7 @@ public void whiteCenter5x5BoardTest() {

@Disabled("Remove to run test")
@Test
@DisplayName("Open corner territory on 5x5 board")
public void openCorner5x5BoardTest() {
GoCounting gocounting = new GoCounting(board5x5);

Expand All @@ -58,6 +62,7 @@ public void openCorner5x5BoardTest() {

@Disabled("Remove to run test")
@Test
@DisplayName("A stone and not a territory on 5x5 board")
public void stoneNotTerritory5x5Board() {
GoCounting gocounting = new GoCounting(board5x5);

Expand All @@ -69,6 +74,7 @@ public void stoneNotTerritory5x5Board() {

@Disabled("Remove to run test")
@Test
@DisplayName("Invalid because X is too low for 5x5 board")
public void invalidXTooLow5x5Board() {
GoCounting gocounting = new GoCounting(board5x5);

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

@Disabled("Remove to run test")
@Test
@DisplayName("Invalid because X is too high for 5x5 board")
public void invalidXTooHigh5x5Board() {
GoCounting gocounting = new GoCounting(board5x5);

Expand All @@ -89,6 +96,7 @@ public void invalidXTooHigh5x5Board() {

@Disabled("Remove to run test")
@Test
@DisplayName("Invalid because Y is too low for 5x5 board")
public void invalidYTooLow5x5Board() {
GoCounting gocounting = new GoCounting(board5x5);

Expand All @@ -99,6 +107,7 @@ public void invalidYTooLow5x5Board() {

@Disabled("Remove to run test")
@Test
@DisplayName("Invalid because Y is too high for 5x5 board")
public void invalidYTooHigh5x5Board() {
GoCounting gocounting = new GoCounting(board5x5);

Expand All @@ -109,6 +118,7 @@ public void invalidYTooHigh5x5Board() {

@Disabled("Remove to run test")
@Test
@DisplayName("One territory is the whole board")
public void oneTerritoryIsWholeBoardTest() {
GoCounting gocounting = new GoCounting(" ");

Expand All @@ -127,6 +137,7 @@ public void oneTerritoryIsWholeBoardTest() {

@Disabled("Remove to run test")
@Test
@DisplayName("Two territory rectangular board")
public void twoTerritoryRectangularBoardTest() {
GoCounting gocounting = new GoCounting(" BW \n BW ");

Expand All @@ -150,6 +161,7 @@ public void twoTerritoryRectangularBoardTest() {

@Disabled("Remove to run test")
@Test
@DisplayName("Two region rectangular board")
public void twoRegionRectangularBoardTest() {
GoCounting gocounting = new GoCounting(" B ");

Expand Down
20 changes: 20 additions & 0 deletions exercises/practice/grade-school/src/test/java/SchoolTest.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 @@ -13,18 +14,21 @@ public void setUp() {
}

@Test
@DisplayName("Roster is empty when no student is added")
public void rosterReturnsAnEmptyListIfThereAreNoStudentsEnrolled() {
assertThat(school.roster()).isEmpty();
}

@Disabled("Remove to run test")
@Test
@DisplayName("Add a student")
public void addAStudent() {
assertThat(school.add("Aimee", 2)).isTrue();
}

@Disabled("Remove to run test")
@Test
@DisplayName("Student is added to the roster")
public void addingAStudentAddsThemToTheSortedRoster() {
school.add("Aimee", 2);

Expand All @@ -33,6 +37,7 @@ public void addingAStudentAddsThemToTheSortedRoster() {

@Disabled("Remove to run test")
@Test
@DisplayName("Adding multiple students in the same grade in the roster")
public void addingMultipleStudentsInTheSameGrade() {
assertThat(school.add("Blair", 2)).isTrue();
assertThat(school.add("James", 2)).isTrue();
Expand All @@ -41,6 +46,7 @@ public void addingMultipleStudentsInTheSameGrade() {

@Disabled("Remove to run test")
@Test
@DisplayName("Multiple students in the same grade are added to the roster")
public void addingMoreStudentsAddsThemToTheSameSortedRoster() {
school.add("Blair", 2);
school.add("James", 2);
Expand All @@ -51,6 +57,7 @@ public void addingMoreStudentsAddsThemToTheSameSortedRoster() {

@Disabled("Remove to run test")
@Test
@DisplayName("Cannot add student to same grade in the roster more than once")
public void cannotAddStudentsToSameGradeInTheRosterMoreThanOnce() {
assertThat(school.add("Blair", 2)).isTrue();
assertThat(school.add("James", 2)).isTrue();
Expand All @@ -60,6 +67,7 @@ public void cannotAddStudentsToSameGradeInTheRosterMoreThanOnce() {

@Disabled("Remove to run test")
@Test
@DisplayName("Student not added to same grade in the roster more than once")
public void studentNotAddedToSameGradeInTheRosterMoreThanOnce() {
school.add("Blair", 2);
school.add("James", 2);
Expand All @@ -71,13 +79,15 @@ public void studentNotAddedToSameGradeInTheRosterMoreThanOnce() {

@Disabled("Remove to run test")
@Test
@DisplayName("Adding students in multiple grades")
public void addingStudentsInMultipleGrades() {
assertThat(school.add("Chelsea", 3)).isTrue();
assertThat(school.add("Logan", 7)).isTrue();
}

@Disabled("Remove to run test")
@Test
@DisplayName("Students in multiple grades are added to the roster")
public void addingStudentsToDifferentGradesAddsThemToTheSameSortedRoster() {
school.add("Chelsea", 3);
school.add("Logan", 7);
Expand All @@ -87,6 +97,7 @@ public void addingStudentsToDifferentGradesAddsThemToTheSameSortedRoster() {

@Disabled("Remove to run test")
@Test
@DisplayName("Cannot add same student to multiple grades in the roster")
public void cannotAddSameStudentToMultipleGradesInTheRoster() {
assertThat(school.add("Blair", 2)).isTrue();
assertThat(school.add("James", 2)).isTrue();
Expand All @@ -96,6 +107,7 @@ public void cannotAddSameStudentToMultipleGradesInTheRoster() {

@Disabled("Remove to run test")
@Test
@DisplayName("Student not added to multiple grades in the roster")
public void studentNotAddedToMultipleGradesInTheRoster() {
school.add("Blair", 2);
school.add("James", 2);
Expand All @@ -107,6 +119,7 @@ public void studentNotAddedToMultipleGradesInTheRoster() {

@Disabled("Remove to run test")
@Test
@DisplayName("Students are sorted by grades in the roster")
public void studentsAreSortedByGradeInTheRoster() {
school.add("Jim", 3);
school.add("Peter", 2);
Expand All @@ -117,6 +130,7 @@ public void studentsAreSortedByGradeInTheRoster() {

@Disabled("Remove to run test")
@Test
@DisplayName("Students are sorted by name in the roster")
public void studentsAreSortedByNameInTheRoster() {
school.add("Peter", 2);
school.add("Zoe", 2);
Expand All @@ -127,6 +141,7 @@ public void studentsAreSortedByNameInTheRoster() {

@Disabled("Remove to run test")
@Test
@DisplayName("Students are sorted by grades and then by name in the roster")
public void studentsAreSortedByGradeAndThenByNameInTheRoster() {
school.add("Peter", 2);
school.add("Anna", 1);
Expand All @@ -141,12 +156,14 @@ public void studentsAreSortedByGradeAndThenByNameInTheRoster() {

@Disabled("Remove to run test")
@Test
@DisplayName("Grade is empty if no students in the roster")
public void gradeIsEmptyIfNoStudentsInTheRoster() {
assertThat(school.grade(1)).isEmpty();
}

@Disabled("Remove to run test")
@Test
@DisplayName("Grade is empty if no students in that grade")
public void gradeIsEmptyIfNoStudentsInThatGrade() {
school.add("Peter", 2);
school.add("Zoe", 2);
Expand All @@ -158,6 +175,7 @@ public void gradeIsEmptyIfNoStudentsInThatGrade() {

@Disabled("Remove to run test")
@Test
@DisplayName("Student not added to same grade more than once")
public void studentNotAddedToTheSameGradeMoreThanOnce() {
school.add("Blair", 2);
school.add("James", 2);
Expand All @@ -169,6 +187,7 @@ public void studentNotAddedToTheSameGradeMoreThanOnce() {

@Disabled("Remove to run test")
@Test
@DisplayName("Student not added to multiple grades")
public void studentNotAddedToMultipleGrades() {
school.add("Blair", 2);
school.add("James", 2);
Expand All @@ -181,6 +200,7 @@ public void studentNotAddedToMultipleGrades() {

@Disabled("Remove to run test")
@Test
@DisplayName("Students are sorted by name in a grade")
public void studentsAreSortedByNameInAGrade() {
school.add("Franklin", 5);
school.add("Bradley", 5);
Expand Down
12 changes: 12 additions & 0 deletions exercises/practice/grains/src/test/java/GrainsTest.java
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.math.BigInteger;
Expand All @@ -11,55 +12,63 @@ public class GrainsTest {
private Grains grains = new Grains();

@Test
@DisplayName("returns the number of grains on the square")
public void countAtSquare1() {
BigInteger result = grains.grainsOnSquare(1);
assertThat(result).isEqualTo(new BigInteger("1"));
}

@Disabled("Remove to run test")
@Test
@DisplayName("grains on square 2")
public void countAtSquare2() {
BigInteger result = grains.grainsOnSquare(2);
assertThat(result).isEqualTo(new BigInteger("2"));
}

@Disabled("Remove to run test")
@Test
@DisplayName("grains on square 3")
public void countAtSquare3() {
BigInteger result = grains.grainsOnSquare(3);
assertThat(result).isEqualTo(new BigInteger("4"));
}

@Disabled("Remove to run test")
@Test
@DisplayName("grains on square 4")
public void countAtSquare4() {
BigInteger result = grains.grainsOnSquare(4);
assertThat(result).isEqualTo(new BigInteger("8"));
}

@Disabled("Remove to run test")
@Test
@DisplayName("grains on square 16")
public void countAtSquare16() {
BigInteger result = grains.grainsOnSquare(16);
assertThat(result).isEqualTo(new BigInteger("32768"));
}

@Disabled("Remove to run test")
@Test
@DisplayName("grains on square 32")
public void countAtSquare32() {
BigInteger result = grains.grainsOnSquare(32);
assertThat(result).isEqualTo(new BigInteger("2147483648"));
}

@Disabled("Remove to run test")
@Test
@DisplayName("grains on square 64")
public void countAtSquare64() {
BigInteger result = grains.grainsOnSquare(64);
assertThat(result).isEqualTo(new BigInteger("9223372036854775808"));
}

@Disabled("Remove to run test")
@Test
@DisplayName("square 0 is invalid")
public void errorOnNullBoardSize() {
assertThatExceptionOfType(IllegalArgumentException.class)
.isThrownBy(() -> grains.grainsOnSquare(0))
Expand All @@ -68,6 +77,7 @@ public void errorOnNullBoardSize() {

@Disabled("Remove to run test")
@Test
@DisplayName("negative square is invalid")
public void errorOnNegativeBoardSize() {
assertThatExceptionOfType(IllegalArgumentException.class)
.isThrownBy(() -> grains.grainsOnSquare(-1))
Expand All @@ -76,6 +86,7 @@ public void errorOnNegativeBoardSize() {

@Disabled("Remove to run test")
@Test
@DisplayName("square greater than 64 is invalid")
public void errorOnExcessiveBoardSize() {
assertThatExceptionOfType(IllegalArgumentException.class)
.isThrownBy(() -> grains.grainsOnSquare(65))
Expand All @@ -84,6 +95,7 @@ public void errorOnExcessiveBoardSize() {

@Disabled("Remove to run test")
@Test
@DisplayName("returns the total number of grains on the board")
public void totalNumberOfGrainsOnABoard() {
BigInteger total = grains.grainsOnBoard();
assertThat(total).isEqualTo(new BigInteger("18446744073709551615"));
Expand Down
Loading