diff options
author | Eduardo Pedroni <e.pedroni91@gmail.com> | 2016-08-14 18:09:22 +0200 |
---|---|---|
committer | Eduardo Pedroni <e.pedroni91@gmail.com> | 2016-08-14 18:09:22 +0200 |
commit | 8cb35b358563e5a81ad9e4aceb123b85222cf4cc (patch) | |
tree | 0d73eebfe29e7d90d4e0d6c5d40a36db75de3fdc /test/eu/equalparts/cardbase/cli | |
parent | 78e369043f95e78b27c265f7eab4d766e54054f4 (diff) |
Implemented some more filtering tests, sorted out validation and exceptions
Diffstat (limited to 'test/eu/equalparts/cardbase/cli')
-rw-r--r-- | test/eu/equalparts/cardbase/cli/CardbaseCLITest.java | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/test/eu/equalparts/cardbase/cli/CardbaseCLITest.java b/test/eu/equalparts/cardbase/cli/CardbaseCLITest.java index 9a98469..87755db 100644 --- a/test/eu/equalparts/cardbase/cli/CardbaseCLITest.java +++ b/test/eu/equalparts/cardbase/cli/CardbaseCLITest.java @@ -860,6 +860,36 @@ public class CardbaseCLITest { assertEquals("Please select a set before removing cards." + EOL, testOutput.toString()); } + @Test + public void removeIntegerOverflowAmount() throws Exception { + uut = new CardbaseCLI(TEST_REMOTE, path("/testbase.cb")); + uut.interpretInput("set FRF"); + + try { + System.setOut(new PrintStream(testOutput)); + uut.interpretInput("remove 129 9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999"); + } finally { + System.setOut(console); + } + + assertEquals("9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999 is not a valid number of cards." + EOL, testOutput.toString()); + } + + @Test + public void removeNonIntAmount() throws Exception { + uut = new CardbaseCLI(TEST_REMOTE, path("/testbase.cb")); + uut.interpretInput("set FRF"); + + try { + System.setOut(new PrintStream(testOutput)); + uut.interpretInput("remove 129 1OO"); + } finally { + System.setOut(console); + } + + assertEquals("1OO is not a valid number of cards." + EOL, testOutput.toString()); + } + /*********************************************************************************** * add() tests, happy path ***********************************************************************************/ @@ -1252,6 +1282,34 @@ public class CardbaseCLITest { assertEquals("Total: 0" + EOL, testOutput.toString()); } + @Test + public void addIntegerOverflowAmount() throws Exception { + uut.interpretInput("set FRF"); + + try { + System.setOut(new PrintStream(testOutput)); + uut.interpretInput("129 9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999"); + } finally { + System.setOut(console); + } + + assertEquals("9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999 is not a valid number of cards." + EOL, testOutput.toString()); + } + + @Test + public void addNonIntAmount() throws Exception { + uut.interpretInput("set FRF"); + + try { + System.setOut(new PrintStream(testOutput)); + uut.interpretInput("129 1OO"); + } finally { + System.setOut(console); + } + + assertEquals("1OO is not a valid number of cards." + EOL, testOutput.toString()); + } + /*********************************************************************************** * undo() tests, happy path ***********************************************************************************/ |