Skip to content

Commit

Permalink
+Fixed exit bug when editting note; +Fixed IntellJ bug
Browse files Browse the repository at this point in the history
  • Loading branch information
RusdiHaizim committed Nov 11, 2019
1 parent 9e2f973 commit ccd0c43
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/main/java/javacake/ui/MainWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ private void handleUserInput() {
if (inputDivider.length == 0) {
throw new CakeException("OOPS!!! I'm sorry, but I don't know what that means.");
}
if ("exit".equals(input)) {
if ("exit".equals(input) && !isWritingNote) {
//must be "exit" exactly, else wont exe
handleExit();
} else if (isQuiz) {
Expand Down
14 changes: 8 additions & 6 deletions src/test/java/QuestionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
import javacake.quiz.Question;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;


public class QuestionTest {
Question dummyQuestion1 = new Question("abc", "3", 5);
Expand All @@ -20,10 +24,8 @@ public void inputValidationNegativeTest() throws CakeException {

@Test
public void inputValidationNotInRangeTest() {
Exception e1 = assertThrows(CakeException.class,
()-> dummyQuestion1.isAnswerCorrect("0"));
assertEquals(e1.getMessage(),
"[!] Please enter option number between 1 and 5! [!]\n");
assertThrows(CakeException.class, ()-> dummyQuestion1.isAnswerCorrect("6"));
Exception e1 = assertThrows(CakeException.class, () -> dummyQuestion1.isAnswerCorrect("0"));
assertEquals(e1.getMessage(), "[!] Please enter option number between 1 and 5! [!]\n");
assertThrows(CakeException.class, () -> dummyQuestion1.isAnswerCorrect("6"));
}
}
8 changes: 4 additions & 4 deletions src/test/java/junittesting/quiztest/ReviewSessionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ void parseInputTest() throws CakeException {
assertTrue(e1.getMessage().contains("You can't use that command here"));

// negative test: out of bounds of number of questions
Exception e2 = assertThrows(CakeException.class,
() -> reviewSession.parseInput(0, String.valueOf(MAX_QUESTIONS + 1)));
Exception e2 = assertThrows(CakeException.class, () -> reviewSession.parseInput(
0, String.valueOf(MAX_QUESTIONS + 1)));
assertTrue(e2.getMessage().contains("That question number is out of range! Try again."));

// negative test: int overflow input
Exception e3 = assertThrows(CakeException.class,
() -> reviewSession.parseInput(0, "2147483700"));
Exception e3 = assertThrows(CakeException.class, () -> reviewSession.parseInput(
0, "2147483700"));
assertTrue(e3.getMessage().contains("number is out of range!"));

// positive test: back
Expand Down

0 comments on commit ccd0c43

Please sign in to comment.