diff --git a/src/main/java/LogginLab.java b/src/main/java/LogginLab.java index 11744ac..dd1aa83 100644 --- a/src/main/java/LogginLab.java +++ b/src/main/java/LogginLab.java @@ -31,7 +31,11 @@ public void setThreshold(Integer threshold) { public boolean thresholdExceeds(Integer limit) { return (this.threshold > limit); } - + public boolean thresholdReached(Integer limit) + { + return (this.threshold < limit); + } // Write a method called thresholdReached, returns true if argument 'limit' is over the threshold. // Write a test for the method in the Test class. + } diff --git a/src/test/java/LogginLabTest.java b/src/test/java/LogginLabTest.java index be1c95f..61640ad 100644 --- a/src/test/java/LogginLabTest.java +++ b/src/test/java/LogginLabTest.java @@ -1,9 +1,11 @@ +import org.junit.Test; + import java.util.logging.Level; import java.util.logging.Logger; import static org.junit.Assert.*; -public class LogginLabTest { +public class LogginLabTest { private final static Logger logger = Logger.getLogger(LogginLab.class.getName()); @org.junit.Before @@ -14,7 +16,7 @@ public void setUp() throws Exception { public void tearDown() throws Exception { } - @org.junit.Test + @Test public void thresholdExceeds() { Integer finalLimit = 5; @@ -31,4 +33,22 @@ public void thresholdExceeds() { } } } + + @Test + public void thresholdReached() { + Integer finalLimit = 5; + Integer largerLimit = 6; + LogginLab lab = new LogginLab(); + lab.setThreshold(finalLimit); + + for (Integer i = 1; i <= largerLimit; i++) { + if (lab.thresholdReached(i)) { + logger.log(Level.INFO, "True " + i); + assertTrue(lab.thresholdReached(i)); + } else { + logger.log(Level.INFO, "False " + i); + assertFalse(lab.thresholdReached(i)); + } + } + } } \ No newline at end of file