1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. import static org.junit.Assert.*;
  2. import org.junit.After;
  3. import org.junit.Before;
  4. import org.junit.Test;
  5. /**
  6. * The test class TrigFunctionsTest.
  7. *
  8. * @author (your name)
  9. * @version (a version number or a date)
  10. */
  11. public class TrigFunctionsTest
  12. {
  13. @Test
  14. public void sinTest(){
  15. TrigFunctions trigFunctions = new TrigFunctions();
  16. double expected = -0.95;
  17. double actual = trigFunctions.sin(5);
  18. assertEquals(expected,actual,0.01);
  19. }
  20. @Test
  21. public void cosTest(){
  22. TrigFunctions trigFunctions = new TrigFunctions();
  23. double expected = 0.28;
  24. double actual = trigFunctions.cos(5);
  25. assertEquals(expected,actual, 0.01);
  26. }
  27. @Test
  28. public void tanTest(){
  29. TrigFunctions trigFunctions = new TrigFunctions();
  30. double expected = -3.38;
  31. double actual = trigFunctions.tan(5);
  32. assertEquals(expected,actual, 0.01);
  33. }
  34. @Test
  35. public void invsinTest(){
  36. TrigFunctions trigFunctions = new TrigFunctions();
  37. double expected = 1.57;
  38. double actual = trigFunctions.invsin(1);
  39. assertEquals(expected,actual, 0.01);
  40. }
  41. @Test
  42. public void invcosTest(){
  43. TrigFunctions trigFunctions = new TrigFunctions();
  44. double expected = 0;
  45. double actual = trigFunctions.invcos(1);
  46. assertEquals(expected,actual, 0.01);
  47. }
  48. @Test
  49. public void invtanTest(){
  50. TrigFunctions trigFunctions = new TrigFunctions();
  51. double expected = 0.79;
  52. double actual = trigFunctions.invtan(1);
  53. assertEquals(expected,actual, 0.01);
  54. }
  55. @Test
  56. public void degTest(){
  57. TrigFunctions trigFunctions = new TrigFunctions();
  58. double expected = 286.48;
  59. double actual = trigFunctions.deg(5);
  60. assertEquals(expected,actual, 0.01);
  61. }
  62. @Test
  63. public void radTest(){
  64. TrigFunctions trigFunctions = new TrigFunctions();
  65. double expected = 0.87;
  66. double actual = trigFunctions.rad(50);
  67. assertEquals(expected,actual, 0.01);
  68. }
  69. }