RealAdvancedTest.java 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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 RealAdvancedTest.
  7. *
  8. * @author (your name)
  9. * @version (a version number or a date)
  10. */
  11. public class RealAdvancedTest
  12. {
  13. /**
  14. * Default constructor for test class RealAdvancedTest
  15. */
  16. public RealAdvancedTest()
  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 squaredTest()
  39. {
  40. RealAdvanced realAdva1 = new RealAdvanced();
  41. assertEquals(9.0, realAdva1.squared(3), 0.1);
  42. }
  43. @Test
  44. public void exponentTest()
  45. {
  46. RealAdvanced realAdva1 = new RealAdvanced();
  47. assertEquals(8.0, realAdva1.exponent(2, 3), 0.1);
  48. }
  49. @Test
  50. public void oppositeTest()
  51. {
  52. RealAdvanced realAdva1 = new RealAdvanced();
  53. assertEquals(2.0, realAdva1.opposite(-2), 0.1);
  54. }
  55. @Test
  56. public void inverseTest()
  57. {
  58. RealAdvanced realAdva1 = new RealAdvanced();
  59. assertEquals(0.5, realAdva1.inverse(2), 0.1);
  60. }
  61. @Test
  62. public void absoluteTest()
  63. {
  64. RealAdvanced realAdva1 = new RealAdvanced();
  65. assertEquals(4.0, realAdva1.absoluteValue(-4), 0.1);
  66. }
  67. @Test
  68. public void squareRootTest()
  69. {
  70. RealAdvanced realAdva1 = new RealAdvanced();
  71. assertEquals(5.0, realAdva1.sqrt(25), 0.1);
  72. }
  73. @Test
  74. public void factorialTest()
  75. {
  76. RealAdvanced realAdva1 = new RealAdvanced();
  77. assertEquals(120.0, realAdva1.factorial(5), 0.1);
  78. }
  79. }