From 8cb35b358563e5a81ad9e4aceb123b85222cf4cc Mon Sep 17 00:00:00 2001 From: Eduardo Pedroni Date: Sun, 14 Aug 2016 18:09:22 +0200 Subject: Implemented some more filtering tests, sorted out validation and exceptions --- .../equalparts/cardbase/cli/CardbaseCLITest.java | 58 ++++++++++++++++++++++ 1 file changed, 58 insertions(+) (limited to 'test/eu/equalparts/cardbase/cli') 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 ***********************************************************************************/ -- cgit v1.2.3