Skip to content

Commit 56302de

Browse files
author
Pan
committed
Junit Test
1 parent cf46536 commit 56302de

File tree

6 files changed

+291
-1
lines changed

6 files changed

+291
-1
lines changed

group11/252308879/dataStructure/src/test/java/org/apn/coding2017/TestJavaUtilArrayList.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ public void testRightShift() {
2525

2626
x = x << 1;
2727
x = x >> 1;
28-
2928
System.out.println(x);
3029
}
3130

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
package org.apn.coding2017.basic;
2+
3+
import org.junit.Before;
4+
import org.junit.Test;
5+
6+
import static org.junit.Assert.*;
7+
8+
/**
9+
* Created by Pan on 2017/2/26.
10+
*/
11+
public class ArrayListTest {
12+
13+
ArrayList arrayList;
14+
15+
@Before
16+
public void before(){
17+
arrayList = new ArrayList();
18+
arrayList.add(1);
19+
arrayList.add(2);
20+
arrayList.add(3);
21+
}
22+
23+
@Test
24+
public void add() throws Exception {
25+
ArrayList arrayList = new ArrayList();
26+
arrayList.add(3);
27+
System.out.println(arrayList);
28+
}
29+
30+
@Test
31+
public void set() throws Exception {
32+
arrayList.add(3);
33+
arrayList.set(0, 4);
34+
System.out.println(arrayList);
35+
}
36+
37+
@Test
38+
public void get() throws Exception {
39+
arrayList.add(1);
40+
arrayList.add(2);
41+
arrayList.add(3);
42+
Object o = arrayList.get(1);
43+
System.out.println(o);
44+
}
45+
46+
@Test
47+
public void remove() throws Exception {
48+
arrayList.add(1);
49+
arrayList.add(2);
50+
arrayList.add(3);
51+
arrayList.remove(1);
52+
System.out.println(arrayList);
53+
}
54+
55+
@Test
56+
public void size() throws Exception {
57+
System.out.println(arrayList.size());
58+
}
59+
60+
@Test
61+
public void isEmpty() throws Exception {
62+
System.out.println(arrayList.isEmpty());
63+
}
64+
65+
@Test
66+
public void iterator() throws Exception {
67+
Iterator iterator = arrayList.iterator();
68+
while (iterator.hasNext()){
69+
Object next = iterator.next();
70+
System.out.println(next);
71+
iterator.remove();
72+
}
73+
System.out.println(arrayList.isEmpty());
74+
}
75+
76+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package org.apn.coding2017.basic;
2+
3+
import org.junit.Before;
4+
import org.junit.Test;
5+
6+
import static org.junit.Assert.*;
7+
8+
/**
9+
* Created by Pan on 2017/2/26.
10+
*/
11+
public class BinaryTreeNodeTest {
12+
13+
BinaryTreeNode binaryTreeNode;
14+
15+
@Before
16+
public void setUp() throws Exception {
17+
binaryTreeNode = new BinaryTreeNode();
18+
binaryTreeNode.push(1, "A");
19+
binaryTreeNode.push(2, "B");
20+
binaryTreeNode.push(3, "C");
21+
binaryTreeNode.push(4, "D");
22+
}
23+
24+
@Test
25+
public void size() throws Exception {
26+
System.out.println(binaryTreeNode.size());
27+
}
28+
29+
@Test
30+
public void get() throws Exception {
31+
System.out.println(binaryTreeNode.get(3));
32+
}
33+
34+
@Test
35+
public void push() throws Exception {
36+
binaryTreeNode.push(5, "E");
37+
System.out.println(binaryTreeNode);
38+
}
39+
40+
}
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
package org.apn.coding2017.basic;
2+
3+
import org.junit.Before;
4+
import org.junit.Test;
5+
6+
import static org.junit.Assert.*;
7+
8+
/**
9+
* Created by Pan on 2017/2/26.
10+
*/
11+
public class LinkedListTest {
12+
13+
LinkedList linkedList;
14+
15+
@Before
16+
public void setUp() throws Exception {
17+
linkedList = new LinkedList();
18+
linkedList.add(0);
19+
linkedList.add(1);
20+
linkedList.add(2);
21+
linkedList.add(3);
22+
}
23+
24+
@Test
25+
public void add() throws Exception {
26+
linkedList.add(0);
27+
System.out.println(linkedList);
28+
}
29+
30+
@Test
31+
public void get() throws Exception {
32+
Object o = linkedList.get(1);
33+
System.out.println(o);
34+
}
35+
36+
@Test
37+
public void remove() throws Exception {
38+
linkedList.remove(1);
39+
System.out.println(linkedList);
40+
}
41+
42+
@Test
43+
public void size() throws Exception {
44+
System.out.println(linkedList.size());
45+
}
46+
47+
@Test
48+
public void addFirst() throws Exception {
49+
linkedList.addFirst(4);
50+
System.out.println(linkedList);
51+
}
52+
53+
@Test
54+
public void addLast() throws Exception {
55+
linkedList.addLast(5);
56+
System.out.println(linkedList);
57+
}
58+
59+
@Test
60+
public void removeFirst() throws Exception {
61+
linkedList.removeFirst();
62+
System.out.println(linkedList);
63+
}
64+
65+
@Test
66+
public void removeLast() throws Exception {
67+
linkedList.removeLast();
68+
System.out.println(linkedList);
69+
}
70+
71+
@Test
72+
public void iterator() throws Exception {
73+
Iterator iterator = linkedList.iterator();
74+
while (iterator.hasNext()){
75+
Object next = iterator.next();
76+
System.out.println(next);
77+
iterator.remove();
78+
}
79+
System.out.println(linkedList);
80+
}
81+
82+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package org.apn.coding2017.basic;
2+
3+
import org.junit.Before;
4+
import org.junit.Test;
5+
6+
import static org.junit.Assert.*;
7+
8+
/**
9+
* Created by Pan on 2017/2/26.
10+
*/
11+
public class QueueTest {
12+
13+
Queue queue;
14+
15+
@Before
16+
public void setUp() throws Exception {
17+
queue = new Queue();
18+
queue.enQueue(1);
19+
queue.enQueue(2);
20+
queue.enQueue(3);
21+
22+
}
23+
24+
@Test
25+
public void enQueue() throws Exception {
26+
queue.enQueue(1);
27+
System.out.println(queue);
28+
}
29+
30+
@Test
31+
public void deQueue() throws Exception {
32+
queue.deQueue();
33+
System.out.println(queue);
34+
}
35+
36+
@Test
37+
public void isEmpty() throws Exception {
38+
System.out.println(queue.isEmpty());
39+
}
40+
41+
@Test
42+
public void size() throws Exception {
43+
System.out.println(queue.size());
44+
}
45+
46+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package org.apn.coding2017.basic;
2+
3+
import org.junit.Before;
4+
import org.junit.Test;
5+
6+
import static org.junit.Assert.*;
7+
8+
/**
9+
* Created by Pan on 2017/2/26.
10+
*/
11+
public class StackTest {
12+
13+
Stack stack;
14+
15+
@Before
16+
public void setUp() throws Exception {
17+
stack = new Stack(3);
18+
stack.push(1);
19+
stack.push(2);
20+
stack.push(3);
21+
}
22+
23+
@Test
24+
public void isEmpty() throws Exception {
25+
System.out.println(stack.isEmpty());
26+
}
27+
28+
@Test
29+
public void size() throws Exception {
30+
System.out.println(stack.size());
31+
}
32+
33+
@Test
34+
public void push() throws Exception {
35+
stack.push(1);
36+
stack.push(2);
37+
stack.push(3);
38+
System.out.println(stack);
39+
}
40+
41+
@Test
42+
public void pop() throws Exception {
43+
stack.pop();
44+
System.out.println(stack);
45+
}
46+
47+
}

0 commit comments

Comments
 (0)