1 | package de.ugoe.cs.util;
|
---|
2 |
|
---|
3 | import org.junit.*;
|
---|
4 | import static org.junit.Assert.*;
|
---|
5 |
|
---|
6 | /**
|
---|
7 | * The class <code>ArrayToolsTest</code> contains tests for the class
|
---|
8 | * <code>{@link ArrayTools}</code>.
|
---|
9 | *
|
---|
10 | * @author Steffen Herbold
|
---|
11 | * @version 1.0
|
---|
12 | */
|
---|
13 | public class ArrayToolsTest {
|
---|
14 |
|
---|
15 | Integer array[];
|
---|
16 |
|
---|
17 | @Test
|
---|
18 | public void testFindIndex_1() throws Exception {
|
---|
19 |
|
---|
20 | Integer target = 3;
|
---|
21 | int expected = 3;
|
---|
22 |
|
---|
23 | int result = ArrayTools.findIndex(array, target);
|
---|
24 |
|
---|
25 | // add additional test code here
|
---|
26 | assertEquals(expected, result);
|
---|
27 | }
|
---|
28 |
|
---|
29 | @Test
|
---|
30 | public void testFindIndex_2() throws Exception {
|
---|
31 |
|
---|
32 | Integer target = 4;
|
---|
33 | int expected = 4;
|
---|
34 |
|
---|
35 | int result = ArrayTools.findIndex(array, target);
|
---|
36 |
|
---|
37 | // add additional test code here
|
---|
38 | assertEquals(expected, result);
|
---|
39 | }
|
---|
40 |
|
---|
41 | @Test
|
---|
42 | public void testFindIndex_3() throws Exception {
|
---|
43 | Integer target = 7;
|
---|
44 |
|
---|
45 | int result = ArrayTools.findIndex(array, target);
|
---|
46 | int expected = -1;
|
---|
47 |
|
---|
48 | // add additional test code here
|
---|
49 | assertEquals(expected, result);
|
---|
50 | }
|
---|
51 |
|
---|
52 | @Test
|
---|
53 | public void testFindIndex_4() throws Exception {
|
---|
54 | Integer target = null;
|
---|
55 | int result = ArrayTools.findIndex(array, target);
|
---|
56 | int expected = 7;
|
---|
57 | assertEquals(expected, result);
|
---|
58 | }
|
---|
59 |
|
---|
60 | @Test
|
---|
61 | public void testFindIndex_5() throws Exception {
|
---|
62 | Object[] array = new Object[0];
|
---|
63 | Object other = new Object();
|
---|
64 |
|
---|
65 | int result = ArrayTools.findIndex(array, other);
|
---|
66 |
|
---|
67 | // add additional test code here
|
---|
68 | assertEquals(-1, result);
|
---|
69 | }
|
---|
70 |
|
---|
71 | @Before
|
---|
72 | public void setUp() throws Exception {
|
---|
73 | array = new Integer[] { 0, 1, 2, 3, 4, 4, 5, null, 6 };
|
---|
74 | }
|
---|
75 |
|
---|
76 | public static void main(String[] args) {
|
---|
77 | new org.junit.runner.JUnitCore().run(ArrayToolsTest.class);
|
---|
78 | }
|
---|
79 | } |
---|