@Test public void shouldSupportDelimiter() throws Exception { // Given IStringCalculator sut = initSut(); // When int result = sut.add("//;\\n1;2"); // Then assertThat(result).isEqualTo(3); }
@Test public void shouldSumMultipleNumbers() throws Exception { // Given IStringCalculator sut = initSut(); // When int result = sut.add("1,2,4,1"); // Then assertThat(result).isEqualTo(8); }
@Test public void shouldHandleLineBreaks() throws Exception { // Given IStringCalculator sut = initSut(); // When int result = sut.add("1\n2,3"); // Then assertThat(result).isEqualTo(6); }
@Test public void shouldReturnThree() throws Exception { // Given IStringCalculator sut = initSut(); // When int result = sut.add("1,2"); // Then assertThat(result).isEqualTo(3); }
@Test public void shouldThrowExceptionWithNegativeNumbers() throws Exception { // Given IStringCalculator sut = initSut(); // When try { int result = sut.add("-1,2,-3"); fail("Exception expected "); } catch (Exception e) { // Then assertThat(e).hasMessage("Negatives not allowed:[-1, -3]"); } }