123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161 |
-
-
- import static org.junit.Assert.*;
- import org.junit.After;
- import org.junit.Before;
- import org.junit.Test;
-
- /**
- * The test class simpleOpTest.
- *
- * @author (your name)
- * @version (a version number or a date)
- */
- public class simpleOpTest
- {
- /**
- * Default constructor for test class simpleOpTest
- */
- public simpleOpTest()
- {
- }
-
- /**
- * Sets up the test fixture.
- *
- * Called before every test case method.
- */
- @Before
- public void setUp()
- {
- }
-
- /**
- * Tears down the test fixture.
- *
- * Called after every test case method.
- */
- @After
- public void tearDown()
- {
- }
-
- @Test
- public void firstAddTest()
- {
- assertEquals(4.0, simpleOp.add(2, 2), 0.1);
- }
-
- @Test
- public void secondAddTestNegative()
- {
- assertEquals(-8.0, simpleOp.add(-100, 92), 0.1);
- }
-
- @Test
- public void firstSubtractTest()
- {
- assertEquals(13.0, simpleOp.sub(25, 12), 0.1);
- }
-
- @Test
- public void secondSubtractTestNegative()
- {
- assertEquals(-8.0, simpleOp.sub(-100, -92), 0.1);
- }
-
- @Test
- public void firstMultiplyTest()
- {
- assertEquals(0.0, simpleOp.mul(3, 0), 0.1);
- }
-
- @Test
- public void secondMultiplyTestNegative()
- {
- assertEquals(125.0, simpleOp.mul(-25, -5), 0.1);
- }
-
-
- @Test
- public void DivideTest2Negative()
- {
- assertEquals(20.0, simpleOp.div(100, 5), 0.1);
- }
-
- @Test
- public void firstSquareTest()
- {
- assertEquals(25.0, simpleOp.squ(5), 0.1);
- }
-
- @Test
- public void secondSquareTestNegative()
- {
- assertEquals(49.0, simpleOp.squ(-7), 0.1);
- }
-
- @Test
- public void firstExponentTest()
- {
- assertEquals(125.0, simpleOp.exp(5, 3), 0.1);
- }
-
- @Test
- public void SecondExponentTestNegative()
- {
- assertEquals(0.008, simpleOp.exp(5, -3), 0.1);
- }
-
- @Test
- public void firstInverseTest()
- {
- assertEquals(0.01, simpleOp.inv(100), 0.1);
- }
-
- @Test
- public void secondInverseTest()
- {
- assertEquals(0.0002, simpleOp.inv(5000), 0.1);
- }
-
- @Test
- public void divideByZero()
- {
- assertEquals(0.0, simpleOp.div(100, 0), 0.1);
- }
-
- @Test
- public void firstInvertTest()
- {
- assertEquals(-237.0, simpleOp.invert(237), 0.1);
- }
-
- @Test
- public void secondInvertTest()
- {
- assertEquals(253.0, simpleOp.invert(-253), 0.1);
- }
-
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
|