123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156 |
-
- import static org.junit.Assert.*;
- import org.junit.After;
- import org.junit.Before;
- import org.junit.Test;
-
- /**
- * The test class CalculationsTest.
- *
- * @author (your name)
- * @version (a version number or a date)
- */
- public class CalculationsTest
- {
-
- @Test
- public void testSquare(){
- // set up data
- double x = 3.0;
-
- //invoke method under test
- double actualResult = Calculations.square(x);
-
- //verify result
- double expectResult = 9.0;
- assertEquals(expectResult, actualResult, 0.001);
-
- }
-
- @Test
- public void testsquareroot(){
- double x = 25.0;
-
- double actualResult = Calculations.squareroot(x);
-
- double expectResult = 5.0;
- assertEquals(expectResult, actualResult, 0.001);
- }
-
- @Test
- public void testinverse(){
- double x = 2;
-
- double actualResult = Calculations.inverse(x);
-
- double expectResult = 0.5;
- assertEquals(expectResult, actualResult, 0.001);
- }
-
- @Test
- public void testinvert(){
- double x = 12.0;
-
- double actualResult = Calculations.invert(x);
-
- double expectResult = -12.0;
- assertEquals(expectResult, actualResult, 0.001);
- }
-
- @Test
- public void testfindSin(){
- double x = 90.0;
-
- double actualResult = Calculations.findSin(x);
-
- double expectResult = 0.8939966636;
- assertEquals(expectResult, actualResult, 0.001);
- }
-
- @Test
- public void testfindCos(){
- double x = 45.0;
-
- double actualResult = Calculations.findCos(x);
-
- double expectResult = 0.52532198881;
- assertEquals(expectResult, actualResult, 0.001);
- }
-
- @Test
- public void testfindTan(){
- double x = 100.0;
-
- double actualResult = Calculations.findTan(x);
-
- double expectResult = -0.58721391515;
- assertEquals(expectResult, actualResult, 0.001);
- }
-
- @Test
- public void testfindAsin(){
- double x = 0.5;
-
- double actualResult = Calculations.findAsin(x);
-
- double expectResult = 0.52359877559;
- assertEquals(expectResult, actualResult, 0.001);
- }
-
- @Test
- public void testfindAcos(){
- double x = 1.0;
-
- double actualResult = Calculations.findAcos(x);
-
- double expectResult = 0;
- assertEquals(expectResult, actualResult, 0.001);
- }
-
- @Test
- public void testfindAtan(){
- double x = 1.0;
-
- double actualResult = Calculations.findAtan(x);
-
- double expectResult = 0.78539816339;
- assertEquals(expectResult, actualResult, 0.001);
- }
-
- @Test
- public void testAddition()
- {
- assertEquals(20.0, Calculations.addition(15, 5), 0.1);
- }
-
-
- @Test
- public void testSubstraction()
- {
- assertEquals(3.0, Calculations.subtraction(5, 2), 0.1);
-
-
- }
-
- @Test
- public void testMultiplication(){
- assertEquals(6.0, Calculations.multiplication(3, 2), 0.1);
- }
-
- @Test
- public void testDivision()
- {
- assertEquals(3.0, Calculations.division(6, 2), 0.1);
- }
-
- @Test
- public void testExponent()
- {
- assertEquals(64.0, Calculations.exponent(4, 3), 0.1);
- }
-
-
- }
-
-
|