123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
-
- 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
- {
- /**
- * Default constructor for test class ShortCalculatorTest
- */
- ShortCalculator shortCalculator;
- public ShortCalculatorTest()
- { shortCalculator = new ShortCalculator();
- }
-
- /**
- * Sets up the test fixture.
- *
- * Called before every test case method.
- */
- @Before
- public void setUp()
- {shortCalculator = new ShortCalculator();
- }
-
- /**
- * Tears down the test fixture.
- *
- * Called after every test case method.
- */
- @After
- public void tearDown()
- {
- }
-
- @Test
- public void add(){
- //:Given
- short expected = 4;
-
- //:When
- short actual = shortCalculator.add((short) 2,(short) 2);
-
-
- //:Then
- assertEquals( expected, actual);
-
- }
- @Test
- public void subtract(){
- //Given
- short expected = 4;
-
- //When
- short actual = shortCalculator.subtract((short) 10, (short) 6);
-
- //Then
- assertEquals( expected, actual);
-
- }
-
- @Test
- public void multiply(){
- //Given
- short expected = 40;
- //When
- short actual = shortCalculator.multiply((short) 10, (short) 4);
- //Then
- assertEquals( expected, actual);
-
- }
-
- @Test
- public void divide(){
- //Given
- short expected = 10;
- //When
- short actual = shortCalculator.divide((short) 40, (short) 4);
- //Then
- assertEquals( expected, actual);
- }
- }
|