TrigTest.java 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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 TrigTest.
  7. *
  8. * @author (your name)
  9. * @version (a version number or a date)
  10. */
  11. public class TrigTest
  12. {
  13. /**
  14. * Default constructor for test class TrigTest
  15. */
  16. public TrigTest()
  17. {
  18. }
  19. /**
  20. * Sets up the test fixture.
  21. *
  22. * Called before every test case method.
  23. */
  24. @Before
  25. public void setUp()
  26. {
  27. }
  28. /**
  29. * Tears down the test fixture.
  30. *
  31. * Called after every test case method.
  32. */
  33. @After
  34. public void tearDown()
  35. {
  36. }
  37. @Test
  38. public void testSIN()
  39. {
  40. Trig trig1 = new Trig();
  41. assertEquals(-0.54402111088, trig1.calcSin(10), 0.1);
  42. }
  43. @Test
  44. public void testCOS()
  45. {
  46. Trig trig1 = new Trig();
  47. assertEquals(-0.83907152907, trig1.calcCos(10), 0.1);
  48. }
  49. @Test
  50. public void testTAN()
  51. {
  52. Trig trig1 = new Trig();
  53. assertEquals(0.64836082745, trig1.calcTan(10), 0.1);
  54. }
  55. @Test
  56. public void testRadtoDeg()
  57. {
  58. Trig trig1 = new Trig();
  59. assertEquals(37.14833901458697, trig1.toDegrees(0.64836082745), 0.1);
  60. }
  61. @Test
  62. public void testArcSin()
  63. {
  64. Trig trig2 = new Trig();
  65. assertEquals(0.523598776, trig2.calcArcsin(0.5), 0.1);
  66. }
  67. @Test
  68. public void testArcTan()
  69. {
  70. Trig trig1 = new Trig();
  71. assertEquals(0.463647609, trig1.calcArctan(0.5), 0.1);
  72. }
  73. @Test
  74. public void testArcCos()
  75. {
  76. Trig trig1 = new Trig();
  77. assertEquals(1.04719755, trig1.calcArccos(0.5), 0.1);
  78. }
  79. @Test
  80. public void testLog()
  81. {
  82. Trig trig1 = new Trig();
  83. assertEquals(1, trig1.calcLog(10), 0.1);
  84. }
  85. }