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
50 changes: 33 additions & 17 deletions exercises/practice/clock/src/test/java/ClockAddTest.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import org.junit.Ignore;
import org.junit.Test;

import static org.junit.Assert.assertEquals;
import static org.assertj.core.api.Assertions.assertThat;

public class ClockAddTest {

Expand All @@ -10,126 +10,142 @@ public class ClockAddTest {
public void addMinutes() {
Clock clock = new Clock(10, 0);
clock.add(3);
assertEquals("10:03", clock.toString());

assertThat(clock.toString()).isEqualTo("10:03");
}

@Ignore("Remove to run test")
@Test
public void addNoMinutes() {
Clock clock = new Clock(6, 41);
clock.add(0);
assertEquals("06:41", clock.toString());

assertThat(clock.toString()).isEqualTo("06:41");
}

@Ignore("Remove to run test")
@Test
public void addToNextHour() {
Clock clock = new Clock(0, 45);
clock.add(40);
assertEquals("01:25", clock.toString());

assertThat(clock.toString()).isEqualTo("01:25");
}

@Ignore("Remove to run test")
@Test
public void addMoreThanOneHour() {
Clock clock = new Clock(10, 0);
clock.add(61);
assertEquals("11:01", clock.toString());

assertThat(clock.toString()).isEqualTo("11:01");
}

@Ignore("Remove to run test")
@Test
public void addMoreThanTwoHoursWithCarry() {
Clock clock = new Clock(0, 45);
clock.add(160);
assertEquals("03:25", clock.toString());

assertThat(clock.toString()).isEqualTo("03:25");
}

@Ignore("Remove to run test")
@Test
public void addAcrossMidnight() {
Clock clock = new Clock(23, 59);
clock.add(2);
assertEquals("00:01", clock.toString());

assertThat(clock.toString()).isEqualTo("00:01");
}

@Ignore("Remove to run test")
@Test
public void addMoreThanOneDay() {
Clock clock = new Clock(5, 32);
clock.add(1500);
assertEquals("06:32", clock.toString());

assertThat(clock.toString()).isEqualTo("06:32");
}

@Ignore("Remove to run test")
@Test
public void addMoreThanTwoDays() {
Clock clock = new Clock(1, 1);
clock.add(3500);
assertEquals("11:21", clock.toString());

assertThat(clock.toString()).isEqualTo("11:21");
}

@Ignore("Remove to run test")
@Test
public void subtractMinutes() {
Clock clock = new Clock(10, 3);
clock.add(-3);
assertEquals("10:00", clock.toString());

assertThat(clock.toString()).isEqualTo("10:00");
}

@Ignore("Remove to run test")
@Test
public void subtractToPreviousHour() {
Clock clock = new Clock(10, 3);
clock.add(-30);
assertEquals("09:33", clock.toString());

assertThat(clock.toString()).isEqualTo("09:33");
}

@Ignore("Remove to run test")
@Test
public void subtractMoreThanAnHour() {
Clock clock = new Clock(10, 3);
clock.add(-70);
assertEquals("08:53", clock.toString());

assertThat(clock.toString()).isEqualTo("08:53");
}

@Ignore("Remove to run test")
@Test
public void subtractAcrossMidnight() {
Clock clock = new Clock(0, 3);
clock.add(-4);
assertEquals("23:59", clock.toString());

assertThat(clock.toString()).isEqualTo("23:59");
}

@Ignore("Remove to run test")
@Test
public void subtractMoreThanTwoHours() {
Clock clock = new Clock(0, 0);
clock.add(-160);
assertEquals("21:20", clock.toString());

assertThat(clock.toString()).isEqualTo("21:20");
}

@Ignore("Remove to run test")
@Test
public void subtractMoreThanTwoHoursWithBorrow() {
Clock clock = new Clock(6, 15);
clock.add(-160);
assertEquals("03:35", clock.toString());

assertThat(clock.toString()).isEqualTo("03:35");
}

@Ignore("Remove to run test")
@Test
public void subtractMoreThanOneDay() {
Clock clock = new Clock(5, 32);
clock.add(-1500);
assertEquals("04:32", clock.toString());

assertThat(clock.toString()).isEqualTo("04:32");
}

@Ignore("Remove to run test")
@Test
public void subtractMoreThanTwoDays() {
Clock clock = new Clock(2, 20);
clock.add(-3000);
assertEquals("00:20", clock.toString());

assertThat(clock.toString()).isEqualTo("00:20");
}
}
42 changes: 21 additions & 21 deletions exercises/practice/clock/src/test/java/ClockCreationTest.java
Original file line number Diff line number Diff line change
@@ -1,126 +1,126 @@
import org.junit.Ignore;
import org.junit.Test;

import static org.junit.Assert.assertEquals;
import static org.assertj.core.api.Assertions.assertThat;

public class ClockCreationTest {

@Test
public void canPrintTimeOnTheHour() {
assertEquals("08:00", new Clock(8, 0).toString());
assertThat(new Clock(8, 0).toString()).isEqualTo("08:00");
}

@Ignore("Remove to run test")
@Test
public void canPrintTimeWithMinutes() {
assertEquals("11:09", new Clock(11, 9).toString());
assertThat(new Clock(11, 9).toString()).isEqualTo("11:09");
}

@Ignore("Remove to run test")
@Test
public void midnightPrintsAsZero() {
assertEquals("00:00", new Clock(24, 0).toString());
assertThat(new Clock(24, 0).toString()).isEqualTo("00:00");
}

@Ignore("Remove to run test")
@Test
public void hourRollsOver() {
assertEquals("01:00", new Clock(25, 0).toString());
assertThat(new Clock(25, 0).toString()).isEqualTo("01:00");
}

@Ignore("Remove to run test")
@Test
public void hourRollsOverContinuously() {
assertEquals("04:00", new Clock(100, 0).toString());
assertThat(new Clock(100, 0).toString()).isEqualTo("04:00");
}

@Ignore("Remove to run test")
@Test
public void sixtyMinutesIsNextHour() {
assertEquals("02:00", new Clock(1, 60).toString());
assertThat(new Clock(1, 60).toString()).isEqualTo("02:00");
}

@Ignore("Remove to run test")
@Test
public void minutesRollOver() {
assertEquals("02:40", new Clock(0, 160).toString());
assertThat(new Clock(0, 160).toString()).isEqualTo("02:40");
}

@Ignore("Remove to run test")
@Test
public void minutesRollOverContinuously() {
assertEquals("04:43", new Clock(0, 1723).toString());
assertThat(new Clock(0, 1723).toString()).isEqualTo("04:43");
}

@Ignore("Remove to run test")
@Test
public void hourAndMinutesRollOver() {
assertEquals("03:40", new Clock(25, 160).toString());
assertThat(new Clock(25, 160).toString()).isEqualTo("03:40");
}

@Ignore("Remove to run test")
@Test
public void hourAndMinutesRollOverContinuously() {
assertEquals("11:01", new Clock(201, 3001).toString());
assertThat(new Clock(201, 3001).toString()).isEqualTo("11:01");
}

@Ignore("Remove to run test")
@Test
public void hourAndMinutesRollOverToExactlyMidnight() {
assertEquals("00:00", new Clock(72, 8640).toString());
assertThat(new Clock(72, 8640).toString()).isEqualTo("00:00");
}

@Ignore("Remove to run test")
@Test
public void negativeHour() {
assertEquals("23:15", new Clock(-1, 15).toString());
assertThat(new Clock(-1, 15).toString()).isEqualTo("23:15");
}

@Ignore("Remove to run test")
@Test
public void negativeHourRollsOver() {
assertEquals("23:00", new Clock(-25, 0).toString());
assertThat(new Clock(-25, 0).toString()).isEqualTo("23:00");
}

@Ignore("Remove to run test")
@Test
public void negativeHourRollsOverContinuously() {
assertEquals("05:00", new Clock(-91, 0).toString());
assertThat(new Clock(-91, 0).toString()).isEqualTo("05:00");
}

@Ignore("Remove to run test")
@Test
public void negativeMinutes() {
assertEquals("00:20", new Clock(1, -40).toString());
assertThat(new Clock(1, -40).toString()).isEqualTo("00:20");
}

@Ignore("Remove to run test")
@Test
public void negativeMinutesRollOver() {
assertEquals("22:20", new Clock(1, -160).toString());
assertThat(new Clock(1, -160).toString()).isEqualTo("22:20");
}

@Ignore("Remove to run test")
@Test
public void negativeMinutesRollOverContinuously() {
assertEquals("16:40", new Clock(1, -4820).toString());
assertThat(new Clock(1, -4820).toString()).isEqualTo("16:40");
}

@Ignore("Remove to run test")
@Test
public void negativeSixtyMinutesIsPreviousHour() {
assertEquals("01:00", new Clock(2, -60).toString());
assertThat(new Clock(2, -60).toString()).isEqualTo("01:00");
}

@Ignore("Remove to run test")
@Test
public void negativeHourAndMinutesBothRollOver() {
assertEquals("20:20", new Clock(-25, -160).toString());
assertThat(new Clock(-25, -160).toString()).isEqualTo("20:20");
}

@Ignore("Remove to run test")
@Test
public void negativeHourAndMinutesBothRollOverContinuously() {
assertEquals("22:10", new Clock(-121, -5810).toString());
assertThat(new Clock(-121, -5810).toString()).isEqualTo("22:10");
}
}
Loading