public void testFailWithUnknownOperation() { try { CaptchaParser.generateHumanReadableCaptcha("02100003"); fail("Function should have thrown a WrongCaptchaOperationException."); } catch (WrongCaptchaLengthException e) { fail("Function should have thrown a WrongCaptchaOperationException."); } catch (WrongCaptchaOperationException e) { // ok } }
public void testFailForWrongLength() { try { CaptchaParser.generateHumanReadableCaptcha("1"); fail("Function should have thrown a WrongCaptchaLengthException."); } catch (WrongCaptchaLengthException e) { // ok } catch (WrongCaptchaOperationException e) { fail("Function should have thrown a WrongCaptchaLengthException."); } }
public void testGenerateCaptchaWithMultiply() { String firstNumber = "01"; String secondNumber = "02"; String goodCaptchaWithSum = firstNumber + CaptchaParser.MULT + secondNumber; try { String result = CaptchaParser.generateHumanReadableCaptcha(goodCaptchaWithSum); assertEquals(firstNumber + " * " + secondNumber + FIXED_CAPTCHA_TAIL, result); } catch (WrongCaptchaLengthException e) { Log.e(TAG, e.getMessage(), e); fail("Function should have not thrown a WrongCaptchaLengthException."); } catch (WrongCaptchaOperationException e) { Log.e(TAG, e.getMessage(), e); fail("Function should have not thrown a WrongCaptchaOperationException."); } }