-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathSampleClassTest.java
More file actions
65 lines (59 loc) · 1.65 KB
/
Copy pathSampleClassTest.java
File metadata and controls
65 lines (59 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.AfterEach;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.assertFalse;
/**
* The test class for SampleClass.
* @author Dr. Jody Paul
* @version Demonstration
*/
public class SampleClassTest extends junit.framework.TestCase {
/** The answer to the ultimate question. */
private static final int ANSWER = 42;
/** Constructor. */
public SampleClassTest() { }
/**
* Set up the test fixture.
* Called before every test case method.
*/
@BeforeEach
protected void setUp() { }
/**
* Tear down the test fixture.
* Called after every test case method.
*/
@AfterEach
protected void tearDown() { }
/**
* Test the toggle() method.
*/
@Test
public void testToggle() {
SampleClass sc = new SampleClass();
assertTrue(sc.toggle());
assertFalse(sc.toggle());
assertTrue(sc.toggle());
}
/**
* Simple tests of fortyTwo method.
* Includes one invalid test.
*/
@Test
public void testFortyTwo() {
SampleClass sm = new SampleClass();
assertEquals(ANSWER, sm.fortyTwo(0));
assertEquals(0, sm.fortyTwo(-ANSWER));
assertEquals(ANSWER - 1, sm.fortyTwo(0));
assertEquals(1, sm.fortyTwo(-41));
}
/**
* Tests of the strangeMethod.
*/
@Test
public void testStrangeMethod() {
SampleClass sm = new SampleClass();
assertTrue(0 < sm.strangeMethod(1));
assertTrue(0 < sm.strangeMethod(-100));
}
}