Skip to content

Instantly share code, notes, and snippets.

@thiagotn
Created January 29, 2016 21:10
Show Gist options
  • Save thiagotn/07b1996b38d743896201 to your computer and use it in GitHub Desktop.
Save thiagotn/07b1996b38d743896201 to your computer and use it in GitHub Desktop.
import static org.junit.Assert.*;
import java.util.Arrays;
import org.junit.Before;
import org.junit.Test;
import dev.util.inscriptions.Calculator;
public class CalculatorTest {
private Calculator calculator;
@Before
public void setUp() throws Exception {
calculator = new Calculator();
}
@Test(expected = IllegalArgumentException.class)
public void testCalcInvalidParams() throws Exception {
calculator.calcWithArray(Arrays.asList("1", "+"));
}
@Test(expected = IllegalArgumentException.class)
public void testCalcInvalidParams2() throws Exception {
calculator.calcWithArray(Arrays.asList("1"));
}
@Test(expected = IllegalArgumentException.class)
public void testCalcInvalidParams3() throws Exception {
calculator.calcWithArray(Arrays.asList("/"));
}
@Test
public void testCalcSum() throws Exception {
Double expected = 1000D;
Double actual = calculator.calcWithArray(Arrays.asList("1", "+", "999"));
assertEquals(expected, actual);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment