123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
-
-
- import static org.junit.Assert.*;
- import org.junit.After;
- import org.junit.Before;
- import org.junit.Test;
-
- /**
- * The test class ShortCalculatorTest.
- *
- * @author (your name)
- * @version (a version number or a date)
- */
- public class ShortCalculatorTest
- {
-
- ShortCalculator shortCalc;
-
- /**
- * Default constructor for test class ShortCalculatorTest
- */
- public ShortCalculatorTest()
- {
- }
-
- /**
- * Sets up the test fixture.
- *
- * Called before every test case method.
- */
- @Before
- public void setUp()
- {
- shortCalc = new ShortCalculator();
- }
-
- /**
- * Tears down the test fixture.
- *
- * Called after every test case method.
- */
- @After
- public void tearDown()
- {
- }
-
-
-
- @Test
- public void shortSumTest(){
- //:Given
- short expected = 20;
-
- //:When
- short actual = shortCalc.sum((short)10,(short)10);
-
- //:Then
- assertEquals(expected, actual);
- }
- @Test
- public void shortDiffTest(){
- //given
- short expected = 15;
-
- //:When
- short actual = shortCalc.diff((short)25,(short)10);
-
- //:Then
- assertEquals(expected, actual);
- }
- @Test
- public void shortMultiplyTest(){
- //given
- short expected = 15;
-
- //:When
- short actual = shortCalc.multiply((short)5,(short)3);
-
- //:Then
- assertEquals(expected, actual);
- }
- @Test
- public void shortDivideTest(){
-
- //given
- short expected = 20;
-
- //:When
- short actual = shortCalc.divide((short)200,(short)10);
-
- //:Then
- assertEquals(expected, actual);
- }
- @Test
- public void shortModTest(){
- //given
- short expected = 1;
-
- //:When
- short actual = shortCalc.remainder((short)10,(short)9);
-
- //:Then
- assertEquals(expected, actual);
- }
-
- }
|