ShortCalculatorTest.java 1.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. import static org.junit.Assert.*;
  2. import org.junit.After;
  3. import org.junit.Before;
  4. import org.junit.Test;
  5. public class ShortCalculatorTest {
  6. ShortCalculator test;
  7. public ShortCalculatorTest() {
  8. test = new ShortCalculator();
  9. }
  10. @Test
  11. public void testAdd(){
  12. //expected
  13. short expected = 10;
  14. //actual
  15. short actual =test.add((short)5,(short)5);
  16. //then
  17. assertEquals(expected, actual);
  18. }
  19. @Test
  20. public void testSubtract(){
  21. //expected
  22. short expected = 5;
  23. //actual
  24. short actual =test.subtract((short)10,(short)5);
  25. //then
  26. assertEquals(expected, actual);
  27. }
  28. @Test
  29. public void testMultiply(){
  30. //expected
  31. short expected = 25;
  32. //actual
  33. short actual =test.multiply((short)5,(short)5);
  34. //then
  35. assertEquals(expected, actual);
  36. }
  37. @Test
  38. public void testDivide(){
  39. //expected
  40. short expected = 5;
  41. //actual
  42. short actual =test.divide((short)10,(short)2);
  43. //then
  44. assertEquals(expected, actual);
  45. }
  46. @Test
  47. public void testRemainder(){
  48. //expected
  49. short expected = 1;
  50. //actual
  51. short actual =test.remainder((short)10,(short)3);
  52. //then
  53. assertEquals(expected, actual);
  54. }
  55. }