-
Notifications
You must be signed in to change notification settings - Fork 641
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Pan
committed
Feb 26, 2017
1 parent
cf46536
commit 56302de
Showing
6 changed files
with
291 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,6 @@ public void testRightShift() { | |
|
||
x = x << 1; | ||
x = x >> 1; | ||
|
||
System.out.println(x); | ||
} | ||
|
||
|
76 changes: 76 additions & 0 deletions
76
group11/252308879/dataStructure/src/test/java/org/apn/coding2017/basic/ArrayListTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package org.apn.coding2017.basic; | ||
|
||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
/** | ||
* Created by Pan on 2017/2/26. | ||
*/ | ||
public class ArrayListTest { | ||
|
||
ArrayList arrayList; | ||
|
||
@Before | ||
public void before(){ | ||
arrayList = new ArrayList(); | ||
arrayList.add(1); | ||
arrayList.add(2); | ||
arrayList.add(3); | ||
} | ||
|
||
@Test | ||
public void add() throws Exception { | ||
ArrayList arrayList = new ArrayList(); | ||
arrayList.add(3); | ||
System.out.println(arrayList); | ||
} | ||
|
||
@Test | ||
public void set() throws Exception { | ||
arrayList.add(3); | ||
arrayList.set(0, 4); | ||
System.out.println(arrayList); | ||
} | ||
|
||
@Test | ||
public void get() throws Exception { | ||
arrayList.add(1); | ||
arrayList.add(2); | ||
arrayList.add(3); | ||
Object o = arrayList.get(1); | ||
System.out.println(o); | ||
} | ||
|
||
@Test | ||
public void remove() throws Exception { | ||
arrayList.add(1); | ||
arrayList.add(2); | ||
arrayList.add(3); | ||
arrayList.remove(1); | ||
System.out.println(arrayList); | ||
} | ||
|
||
@Test | ||
public void size() throws Exception { | ||
System.out.println(arrayList.size()); | ||
} | ||
|
||
@Test | ||
public void isEmpty() throws Exception { | ||
System.out.println(arrayList.isEmpty()); | ||
} | ||
|
||
@Test | ||
public void iterator() throws Exception { | ||
Iterator iterator = arrayList.iterator(); | ||
while (iterator.hasNext()){ | ||
Object next = iterator.next(); | ||
System.out.println(next); | ||
iterator.remove(); | ||
} | ||
System.out.println(arrayList.isEmpty()); | ||
} | ||
|
||
} |
40 changes: 40 additions & 0 deletions
40
...11/252308879/dataStructure/src/test/java/org/apn/coding2017/basic/BinaryTreeNodeTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package org.apn.coding2017.basic; | ||
|
||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
/** | ||
* Created by Pan on 2017/2/26. | ||
*/ | ||
public class BinaryTreeNodeTest { | ||
|
||
BinaryTreeNode binaryTreeNode; | ||
|
||
@Before | ||
public void setUp() throws Exception { | ||
binaryTreeNode = new BinaryTreeNode(); | ||
binaryTreeNode.push(1, "A"); | ||
binaryTreeNode.push(2, "B"); | ||
binaryTreeNode.push(3, "C"); | ||
binaryTreeNode.push(4, "D"); | ||
} | ||
|
||
@Test | ||
public void size() throws Exception { | ||
System.out.println(binaryTreeNode.size()); | ||
} | ||
|
||
@Test | ||
public void get() throws Exception { | ||
System.out.println(binaryTreeNode.get(3)); | ||
} | ||
|
||
@Test | ||
public void push() throws Exception { | ||
binaryTreeNode.push(5, "E"); | ||
System.out.println(binaryTreeNode); | ||
} | ||
|
||
} |
82 changes: 82 additions & 0 deletions
82
group11/252308879/dataStructure/src/test/java/org/apn/coding2017/basic/LinkedListTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
package org.apn.coding2017.basic; | ||
|
||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
/** | ||
* Created by Pan on 2017/2/26. | ||
*/ | ||
public class LinkedListTest { | ||
|
||
LinkedList linkedList; | ||
|
||
@Before | ||
public void setUp() throws Exception { | ||
linkedList = new LinkedList(); | ||
linkedList.add(0); | ||
linkedList.add(1); | ||
linkedList.add(2); | ||
linkedList.add(3); | ||
} | ||
|
||
@Test | ||
public void add() throws Exception { | ||
linkedList.add(0); | ||
System.out.println(linkedList); | ||
} | ||
|
||
@Test | ||
public void get() throws Exception { | ||
Object o = linkedList.get(1); | ||
System.out.println(o); | ||
} | ||
|
||
@Test | ||
public void remove() throws Exception { | ||
linkedList.remove(1); | ||
System.out.println(linkedList); | ||
} | ||
|
||
@Test | ||
public void size() throws Exception { | ||
System.out.println(linkedList.size()); | ||
} | ||
|
||
@Test | ||
public void addFirst() throws Exception { | ||
linkedList.addFirst(4); | ||
System.out.println(linkedList); | ||
} | ||
|
||
@Test | ||
public void addLast() throws Exception { | ||
linkedList.addLast(5); | ||
System.out.println(linkedList); | ||
} | ||
|
||
@Test | ||
public void removeFirst() throws Exception { | ||
linkedList.removeFirst(); | ||
System.out.println(linkedList); | ||
} | ||
|
||
@Test | ||
public void removeLast() throws Exception { | ||
linkedList.removeLast(); | ||
System.out.println(linkedList); | ||
} | ||
|
||
@Test | ||
public void iterator() throws Exception { | ||
Iterator iterator = linkedList.iterator(); | ||
while (iterator.hasNext()){ | ||
Object next = iterator.next(); | ||
System.out.println(next); | ||
iterator.remove(); | ||
} | ||
System.out.println(linkedList); | ||
} | ||
|
||
} |
46 changes: 46 additions & 0 deletions
46
group11/252308879/dataStructure/src/test/java/org/apn/coding2017/basic/QueueTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package org.apn.coding2017.basic; | ||
|
||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
/** | ||
* Created by Pan on 2017/2/26. | ||
*/ | ||
public class QueueTest { | ||
|
||
Queue queue; | ||
|
||
@Before | ||
public void setUp() throws Exception { | ||
queue = new Queue(); | ||
queue.enQueue(1); | ||
queue.enQueue(2); | ||
queue.enQueue(3); | ||
|
||
} | ||
|
||
@Test | ||
public void enQueue() throws Exception { | ||
queue.enQueue(1); | ||
System.out.println(queue); | ||
} | ||
|
||
@Test | ||
public void deQueue() throws Exception { | ||
queue.deQueue(); | ||
System.out.println(queue); | ||
} | ||
|
||
@Test | ||
public void isEmpty() throws Exception { | ||
System.out.println(queue.isEmpty()); | ||
} | ||
|
||
@Test | ||
public void size() throws Exception { | ||
System.out.println(queue.size()); | ||
} | ||
|
||
} |
47 changes: 47 additions & 0 deletions
47
group11/252308879/dataStructure/src/test/java/org/apn/coding2017/basic/StackTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package org.apn.coding2017.basic; | ||
|
||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
/** | ||
* Created by Pan on 2017/2/26. | ||
*/ | ||
public class StackTest { | ||
|
||
Stack stack; | ||
|
||
@Before | ||
public void setUp() throws Exception { | ||
stack = new Stack(3); | ||
stack.push(1); | ||
stack.push(2); | ||
stack.push(3); | ||
} | ||
|
||
@Test | ||
public void isEmpty() throws Exception { | ||
System.out.println(stack.isEmpty()); | ||
} | ||
|
||
@Test | ||
public void size() throws Exception { | ||
System.out.println(stack.size()); | ||
} | ||
|
||
@Test | ||
public void push() throws Exception { | ||
stack.push(1); | ||
stack.push(2); | ||
stack.push(3); | ||
System.out.println(stack); | ||
} | ||
|
||
@Test | ||
public void pop() throws Exception { | ||
stack.pop(); | ||
System.out.println(stack); | ||
} | ||
|
||
} |