ShortCalculatorTest.java 1.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. import org.junit.Assert;
  2. import org.junit.Before;
  3. import org.junit.Test;
  4. public class ShortCalculatorTest {
  5. private ShortCalculator shortCalculator;
  6. @Before
  7. public void setUp(){
  8. shortCalculator = new ShortCalculator();
  9. }
  10. @Test
  11. public void shortVariableSumTest(){
  12. //:Given
  13. short expected = 30;
  14. //:When
  15. short actual = shortCalculator.sum((short)10,(short)20);
  16. //:Then
  17. Assert.assertEquals(expected, actual);
  18. }
  19. @Test
  20. public void shortVariablediffTest(){
  21. //:Given
  22. short expected = 10;
  23. //:When
  24. short actual = shortCalculator.diff((short)20,(short)10);
  25. //:Then
  26. Assert.assertEquals(expected, actual);
  27. }
  28. @Test
  29. public void shortVariableProdTest(){
  30. //:Given
  31. short expected = 200;
  32. //:When
  33. short actual = shortCalculator.prod((short)10,(short)20);
  34. //:Then
  35. Assert.assertEquals(expected, actual);
  36. }
  37. @Test
  38. public void shortVariableQuotTest(){
  39. //:Given
  40. short expected = 2;
  41. //:When
  42. short actual = shortCalculator.quot((short)20,(short)10);
  43. //:Then
  44. Assert.assertEquals(expected, actual);
  45. }
  46. @Test
  47. public void shortVariableRemainderTest(){
  48. //:Given
  49. short expected = 1;
  50. //:When
  51. short actual = shortCalculator.remain((short)10,(short)3);
  52. //:Then
  53. Assert.assertEquals(expected, actual);
  54. }
  55. }