123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
-
-
- import org.junit.Assert;
- import org.junit.After;
- import org.junit.Before;
- import org.junit.Test;
-
- /**
- * The test class CalculatorTest.
- *
- * @author (your name)
- * @version (a version number or a date)
- */
- public class CalculatorTest
- {
- @Test
- public void additionTest(){
- //:Given
- Double expected = Double.valueOf(3);
- //:When
- Calculator c = new Calculator();
- Double actual = c.add(0,3);
- //:Then
- Assert.assertEquals(expected, actual);
- }
- @Test
- public void subtractionTest(){
- //:Given
- Double expected = Double.valueOf(2-1);
- //:When
- Calculator c = new Calculator();
- Double actual = c.subtract(2, 1);
- //Then
- Assert.assertEquals(expected, actual);
- }
- @Test
- public void mutliplicationTest(){
- //:Given
- Double expected = Double.valueOf(2*3);
- //:When
- Calculator c = new Calculator();
- Double actual = c.multiply(2, 3);
- //:Then
- Assert.assertEquals(expected, actual);
- }
- @Test
- public void divisionTest(){
- //:Given
- Double expected = Double.valueOf(4/3);
- //:When
- Calculator c = new Calculator();
- Double actual = c.divide(4,3);
- //:Then
- Assert.assertEquals(expected, actual);
- }
- @Test
- public void powTest(){
- //:Given
- Double expected = Double.valueOf(9);
- //:When
- Calculator c = new Calculator();
- Double actual = c.pow(3,2);
- //:Then
- Assert.assertEquals(expected, actual);
- }
- @Test
- public void squareTest(){
- //:Given
- Double expected = Double.valueOf(225);
- //:When
- Calculator c = new Calculator();
- Double actual = c.square(15);
- //:Then
- Assert.assertEquals(expected, actual);
- }
- @Test
- public void sqrtTest(){
- //:Given
- Double expected = Double.valueOf(Math.sqrt(4));
- //:When
- Calculator c = new Calculator();
- Double actual = c.squareRoot(4);
- //:Then
- Assert.assertEquals(expected, actual);
- }
- }
|