ScientificFunctionsTest.java 2.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. import org.junit.Assert;
  2. import org.junit.Test;
  3. /**
  4. * The test class ScientificFunctionsTest.
  5. *
  6. * @author (your name)
  7. * @version (a version number or a date)
  8. */
  9. public class ScientificFunctionsTest
  10. { ScientificFunctions scientificFunctionsTest = new ScientificFunctions();
  11. /**
  12. * Default constructor for test class ScientificFunctionsTest
  13. */
  14. public ScientificFunctionsTest()
  15. {
  16. }
  17. @Test
  18. public void testSquared(){
  19. double actual = ScientificFunctions.sqr(4);
  20. double expected = 16;
  21. Assert.assertEquals(expected,actual,1e-8);
  22. }
  23. @Test
  24. public void testSqRoot(){
  25. double actual = ScientificFunctions.sqRoot(4);
  26. double expected = 2;
  27. Assert.assertEquals(expected,actual,1e-8);
  28. }
  29. @Test
  30. public void testInvFraction(){
  31. double actual = ScientificFunctions.invFraction(2);
  32. double expected = .5;
  33. Assert.assertEquals(expected,actual,1e-8);
  34. }
  35. @Test
  36. public void testInvSign(){
  37. double actual = ScientificFunctions.invSign(3);
  38. double expected = -3;
  39. Assert.assertEquals(expected,actual,1e-8);
  40. }
  41. @Test
  42. public void testCosine(){
  43. double actual = ScientificFunctions.cosine(3);
  44. double expected = 0.9986295347545738;
  45. Assert.assertEquals(expected,actual,1e-8);
  46. }
  47. @Test
  48. public void testSine(){
  49. double actual = ScientificFunctions.sin(3);
  50. double expected = 0.05233595624294383;
  51. Assert.assertEquals(expected,actual,1e-8);
  52. }
  53. @Test
  54. public void testTan(){
  55. double actual = ScientificFunctions.tan(3);
  56. double expected = 0.052407779283041196;
  57. Assert.assertEquals(expected,actual,1e-8);
  58. }
  59. @Test
  60. public void testAcosine(){
  61. double actual = ScientificFunctions.acosin(3);
  62. double expected = 1.518412495074819;
  63. Assert.assertEquals(expected,actual,1e-8);
  64. }
  65. @Test
  66. public void testAsin(){
  67. double actual = ScientificFunctions.asin(3);
  68. double expected = 0.05238383172007756;
  69. Assert.assertEquals(expected,actual,1e-8);
  70. }
  71. @Test
  72. public void testATangent(){
  73. double actual = ScientificFunctions.atan(3);
  74. double expected = 0.05231210692238478;
  75. Assert.assertEquals(expected,actual,1e-8);
  76. }
  77. }