123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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 MathMethodsTest.
  7. *
  8. * @author (your name)
  9. * @version (a version number or a date)
  10. */
  11. public class MathMethodsTest
  12. {
  13. /**
  14. * Default constructor for test class MathMethodsTest
  15. */
  16. public MathMethodsTest()
  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 testSquareRoot()
  39. {
  40. assertEquals(16.0, MathMethods.squareRoot(256), 0.1);
  41. }
  42. @Test
  43. public void testInvertPositive()
  44. {
  45. assertEquals(-5.0, MathMethods.invert(5), 0.1);
  46. }
  47. @Test
  48. public void testInvertNegative()
  49. {
  50. assertEquals(11.0, MathMethods.invert(-11), 0.1);
  51. }
  52. @Test
  53. public void testSin()
  54. {
  55. assertEquals(-0.26237485370392877, MathMethods.sin(50), 0.1);
  56. }
  57. @Test
  58. public void testDegToRad()
  59. {
  60. assertEquals(0.3490658503988659, MathMethods.degToRad(20), 0.1);
  61. }
  62. @Test
  63. public void testRadToDeg()
  64. {
  65. assertEquals(57.2957791308232, MathMethods.radToDeg(1), 0.1);
  66. }
  67. // @Test
  68. // public void testOctalDisplay()
  69. // {
  70. // MathMethods mathMethods1 = new MathMethods();
  71. // mathMethods1.memory = 20;
  72. // assertEquals("0 24", MathMethods.switchDisplayMode("octal"));
  73. // }
  74. @Test
  75. public void testInverseSine()
  76. {
  77. assertEquals(1.5707963267948966, MathMethods.iSin(1), 0.1);
  78. }
  79. public void squareTest()
  80. {
  81. assertEquals(16, MathMethods.square(4), 0.1);
  82. }
  83. @Test
  84. public void tangentTest()
  85. {
  86. assertEquals(-3.380515005246586, MathMethods.tangent(5), 0.1);
  87. }
  88. @Test
  89. public void inverseTangentTest()
  90. {
  91. assertEquals(1.550798992821746, MathMethods.iTan(50), 0.1);
  92. }
  93. @Test
  94. public void inverseTest()
  95. {
  96. assertEquals(.1, MathMethods.inverse(10), 0.1);
  97. }
  98. }