123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
-
- 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 shortCalculator;
- /**
- * Default constructor for test class ShortCalculatorTest
- */
- public ShortCalculatorTest()
- {
- }
-
- /**
- * 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 sum(){//:Given
- short expected = 20;
-
- //:When
- short actual = shortCalculator.sum((short)10 , (short)10);
-
- //:Then
- assertEquals( expected, actual);
-
- }
-
- @Test
- public void subtract(){//:Given
- short expected = 20;
-
- //:When
- short actual = shortCalculator.subtract((short)35 , (short)15);
-
- //:Then
- assertEquals( expected, actual);
-
- }
-
- @Test
- public void divide(){//:Given
- short expected = 1;
-
- //:When
- short actual = shortCalculator.divide((short)10 , (short)10);
-
- //:Then
- assertEquals( expected, actual);
-
- }
-
- @Test
- public void multiply(){//
- short expected = 100;
-
- //:When
- short actual = shortCalculator.multiply((short)20 , (short)5);
-
- //:Then
- assertEquals(expected, actual);
-
- }
-
- @Test
- public void mod(){//:Given
- short expected = 0;
-
- //:When
- short actual = shortCalculator.mod((short)10 , (short)10);
-
- //:Then
- assertEquals( expected, actual);
-
- }
- }
|