CoreTest.java 2.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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 CoreTest.
  7. *
  8. * @author (your name)
  9. * @version (a version number or a date)
  10. */
  11. public class CoreTest
  12. {
  13. /**
  14. * Default constructor for test class CoreTest
  15. */
  16. private Core test;
  17. public CoreTest()
  18. {
  19. }
  20. /**
  21. * Sets up the test fixture.
  22. *
  23. * Called before every test case method.
  24. */
  25. @Before
  26. public void setUp()
  27. {
  28. Core test = new Core();
  29. }
  30. /**
  31. * Tears down the test fixture.
  32. *
  33. * Called after every test case method.
  34. */
  35. @After
  36. public void tearDown()
  37. {
  38. }
  39. @Test
  40. public void testAdd()
  41. {
  42. //expected
  43. double expected = 2.0;
  44. //actual
  45. double actual = test.add(1.0,1.0);
  46. //assertion
  47. assertEquals(expected, actual, 0.1);
  48. }
  49. @Test
  50. public void testSubtract()
  51. {
  52. //expected
  53. double expected = 0.0;
  54. //actual
  55. double actual = test.subtract(2.0,2.0);
  56. //assertion
  57. assertEquals(expected, actual, 0.1);
  58. }
  59. @Test
  60. public void testDivide()
  61. {
  62. //expected
  63. double expected = 1.0;
  64. //actual
  65. double actual = test.divide(2.0,2.0);
  66. //assertion
  67. assertEquals(expected, actual, 0.1);
  68. }
  69. @Test
  70. public void testMultiply()
  71. {
  72. //expected
  73. double expected = 4.0;
  74. //actual
  75. double actual = test.multiply(2.0,2.0);
  76. //assertion
  77. assertEquals(expected, actual, 0.1);
  78. }
  79. @Test
  80. public void testsquareRoot()
  81. {
  82. //expected
  83. double expected = 3.0;
  84. //actual
  85. double actual = test.squareRoot(9.0);
  86. //assertion
  87. assertEquals(expected, actual, 0.1);
  88. }
  89. @Test
  90. public void testexponentiation()
  91. {
  92. //expected
  93. double expected = 4;
  94. //actual
  95. double actual = test.exponentiation(2.0,2.0);
  96. //assertion
  97. assertEquals(expected, actual, 0.1);
  98. }
  99. @Test
  100. public void testinverse()
  101. {
  102. //expected
  103. double expected = 0.25;
  104. //actual
  105. double actual = test.inverse(4.0);
  106. //assertion
  107. assertEquals(expected, actual, 0.1);
  108. }
  109. @Test
  110. public void testreverse()
  111. {
  112. //expected
  113. double expected = -4.0;
  114. //actual
  115. double actual = test.reverse(4.0);
  116. //assertion
  117. assertEquals(expected, actual, 0.1);
  118. }
  119. }