ShortCalculatorTest.java 1.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. import org.junit.Assert;
  2. import org.junit.After;
  3. import org.junit.Before;
  4. import org.junit.Test;
  5. public class ShortCalculatorTest {
  6. private ShortCalculator shortcalc;
  7. @Before
  8. public void setUp(){
  9. shortcalc = new ShortCalculator();
  10. }
  11. @Test
  12. public void addTest(){
  13. //:Given
  14. short expected = 300;
  15. //:When
  16. short actual = shortcalc.add((short)100,(short)200);
  17. //:Then
  18. Assert.assertEquals("Values should be equal", expected, actual);
  19. }
  20. @Test
  21. public void addBigNumberTest(){
  22. //:Given
  23. short expected = (short)110000;
  24. //:When
  25. short actual = shortcalc.add((short)50000,(short)60000);
  26. //:Then
  27. Assert.assertEquals("Values should be equal", expected, actual);
  28. }
  29. @Test
  30. public void subtractTest(){
  31. //:Given
  32. short expected = 1000;
  33. //:When
  34. short actual = shortcalc.subtract((short)2000,(short)1000);
  35. //:Then
  36. Assert.assertEquals("Values should be equal", expected, actual);
  37. }
  38. @Test
  39. public void multiplyTest(){
  40. //:Given
  41. short expected = 363;
  42. //:When
  43. short actual = shortcalc.multiply((short)33,(short)11);
  44. //:Then
  45. Assert.assertEquals("Values should be equal", expected, actual);
  46. }
  47. @Test
  48. public void divideTest(){
  49. //:Given
  50. short expected = 8;
  51. //:When
  52. short actual = shortcalc.divide((short)88,(short)11);
  53. //:Then
  54. Assert.assertEquals("Values should be equal", expected, actual);
  55. }
  56. @Test
  57. public void remainderTest(){
  58. //:Given
  59. short expected = 5;
  60. //:When
  61. short actual = shortcalc.remainder((short)105,(short)10);
  62. //:Then
  63. Assert.assertEquals("Values should be equal", expected, actual);
  64. }
  65. }