123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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 BasicTest.
  7. *
  8. * @author (your name)
  9. * @version (a version number or a date)
  10. */
  11. public class BasicTest
  12. {
  13. /**
  14. * Default constructor for test class BasicTest
  15. */
  16. public BasicTest()
  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 testAdd()
  39. {
  40. Basic basic1 = new Basic();
  41. assertEquals(14, basic1.getSum(4, 10), 0.1);
  42. }
  43. @Test
  44. public void testAddDec()
  45. {
  46. Basic basic1 = new Basic();
  47. assertEquals(13.27, basic1.getSum(13.2, 0.07), 0.1);
  48. }
  49. @Test
  50. public void testAddNeg()
  51. {
  52. Basic basic1 = new Basic();
  53. basic1.Basic();
  54. assertEquals(6, basic1.getSum(-3, 9), 0.1);
  55. }
  56. @Test
  57. public void testSub()
  58. {
  59. Basic basic1 = new Basic();
  60. assertEquals(5, basic1.getDiff(10, 5), 0.1);
  61. }
  62. @Test
  63. public void testSubDec()
  64. {
  65. Basic basic1 = new Basic();
  66. assertEquals(4.65, basic1.getDiff(13.2, 8.55), 0.1);
  67. }
  68. @Test
  69. public void testSubNeg()
  70. {
  71. Basic basic1 = new Basic();
  72. assertEquals(18, basic1.getDiff(6, -12), 0.1);
  73. }
  74. @Test
  75. public void testMul()
  76. {
  77. Basic basic1 = new Basic();
  78. assertEquals(15, basic1.getProduct(3, 5), 0.1);
  79. }
  80. @Test
  81. public void testMulDec()
  82. {
  83. Basic basic1 = new Basic();
  84. assertEquals(6.8, basic1.getProduct(3.4, 2), 0.1);
  85. }
  86. @Test
  87. public void testMulNeg()
  88. {
  89. Basic basic1 = new Basic();
  90. assertEquals(10, basic1.getProduct(-2, -5), 0.1);
  91. }
  92. @Test
  93. public void testDiv()
  94. {
  95. Basic basic1 = new Basic();
  96. assertEquals(4, basic1.getQuotient(12, 3), 0.1);
  97. }
  98. @Test
  99. public void testDivDec()
  100. {
  101. Basic basic1 = new Basic();
  102. assertEquals(7.4, basic1.getQuotient(14.8, 2), 0.1);
  103. }
  104. @Test
  105. public void testDivNeg()
  106. {
  107. Basic basic1 = new Basic();
  108. assertEquals(-3, basic1.getQuotient(-12, 4), 0.1);
  109. }
  110. }