Skip to content

Commit

Permalink
Merge pull request #6 from zhan2016/master
Browse files Browse the repository at this point in the history
20170224
  • Loading branch information
gaodekui authored Feb 24, 2017
2 parents b896ee3 + 1082e16 commit e3c7381
Show file tree
Hide file tree
Showing 17 changed files with 1,298 additions and 3 deletions.
3 changes: 3 additions & 0 deletions group16/2562124714/.idea/dictionaries/zhangwj.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions group16/2562124714/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions group16/2562124714/.idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

780 changes: 780 additions & 0 deletions group16/2562124714/.idea/workspace.xml

Large diffs are not rendered by default.

21 changes: 21 additions & 0 deletions group16/2562124714/2562124714.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module-library">
<library name="JUnit4">
<CLASSES>
<root url="jar://$APPLICATION_HOME_DIR$/lib/junit-4.12.jar!/" />
<root url="jar://$APPLICATION_HOME_DIR$/lib/hamcrest-core-1.3.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
</component>
</module>
70 changes: 70 additions & 0 deletions group16/2562124714/src/Test/ArrayListTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
package Test;

import com.coding.basic.ArrayList;
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;

import static org.junit.Assert.*;

/**
* Created by zhangwj on 2017/2/23.
*/
public class ArrayListTest {
private static ArrayList arraylist = new ArrayList();
@BeforeClass
public static void setUp() throws Exception {

System.out.println("初始化变量");
for (Integer i = 0; i < 5; i++)
{
arraylist.add(i);
}


}

@After
public void tearDown() throws Exception {

}

@Test
public void add() throws Exception {
Integer i = arraylist.size();
Integer AddElement = 999;
arraylist.add(AddElement);
assertEquals(i + 1, arraylist.size());
assertEquals(AddElement, arraylist.get(arraylist.size()));
arraylist.remove(arraylist.size());
}

@Test
public void add1() throws Exception {
Integer AddElement = 999;
arraylist.add(1, AddElement);
assertEquals(AddElement, arraylist.get(1));
arraylist.remove(1);
}

@Test
public void get() throws Exception {
assertEquals(null, arraylist.get(9999));
}

@Test
public void remove() throws Exception {
Integer i = (Integer)arraylist.get(1);
assertEquals(i, arraylist.remove(1));
arraylist.add(1, i);

}

@Test
public void size() throws Exception {
assertEquals(5, arraylist.size());

}

}
100 changes: 100 additions & 0 deletions group16/2562124714/src/Test/BinaryTreeNodeTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
package Test;

import com.coding.basic.BinaryTreeNode;
import com.coding.basic.TreeData;
import com.sun.org.apache.bcel.internal.generic.NEW;
import org.junit.Before;
import org.junit.Test;

import static org.junit.Assert.*;

/**
* Created by zhangwj on 2017/2/23.
*/
public class BinaryTreeNodeTest {
private BinaryTreeNode binaryTree = new BinaryTreeNode();
@Before
public void setUp() throws Exception {
//System.out.println("初始化二叉树,5, 4, 7");
TreeData element = new TreeData();
element.setT((Integer)5);
binaryTree.insert(element);
TreeData element2 = new TreeData();
element2.setT((Integer)4);
binaryTree.insert(element2);
TreeData element3 = new TreeData();
element3.setT((Integer)7);
binaryTree.insert(element3);
// binaryTree.PriOder(this.binaryTree);
}

@Test
public void getData() throws Exception {
assertEquals(5, binaryTree.getData().getT());

}

@Test
public void setData() throws Exception {
TreeData element = new TreeData();
element.setT(6);
binaryTree.setData(element);
assertEquals(6, binaryTree.getData().getT());
// binaryTree.PriOder(this.binaryTree);

}

@Test
public void getLeft() throws Exception {
assertEquals(4, binaryTree.getLeft().getData().getT());

}

@Test
public void setLeft() throws Exception {
TreeData element = new TreeData();
element.setT(2);
BinaryTreeNode NewTreeNode = new BinaryTreeNode();
NewTreeNode.setData(element);
binaryTree.setLeft(NewTreeNode);
assertEquals(2, binaryTree.getLeft().getData().getT());
// binaryTree.PriOder(this.binaryTree);
}

@Test
public void getRight() throws Exception {
assertEquals(7, binaryTree.getRight().getData().getT());

}

@Test
public void setRight() throws Exception {
TreeData element = new TreeData();
element.setT(9);
BinaryTreeNode NewTreeNode = new BinaryTreeNode();
NewTreeNode.setData(element);
binaryTree.setRight(NewTreeNode);
assertEquals(9, binaryTree.getRight().getData().getT());
}

@Test
public void priOder() throws Exception {


}

@Test
public void insert() throws Exception {
TreeData element = new TreeData();
element.setT(2);
binaryTree.insert(element);
binaryTree.PriOder(this.binaryTree);
element.setT(9);
binaryTree.insert(element);
binaryTree.PriOder(this.binaryTree);
element.setT(8);
// binaryTree.PriOder(this.binaryTree);

}

}
81 changes: 81 additions & 0 deletions group16/2562124714/src/Test/LinkedListTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
package Test;

import com.coding.basic.LinkedList;
import org.junit.Before;
import org.junit.Test;

import static org.junit.Assert.*;

/**
* Created by zhangwj on 2017/2/23.
*/
public class LinkedListTest {
private LinkedList linkedlist = new LinkedList();

@Before
public void Init()
{
System.out.println("初始化");
linkedlist.add(9.9);
linkedlist.add(9.99);
}


@Test
public void add() throws Exception {
linkedlist.add(8.8);
assertEquals(3, linkedlist.size());
System.out.println("after add size is " + linkedlist.size());
System.out.println("after add last element is " + linkedlist.get(linkedlist.size()));

}

@Test
public void add1() throws Exception {
linkedlist.add(2, 7.7);
assertEquals(3, linkedlist.size());
System.out.println("after add in 2th size is " + linkedlist.size());
System.out.println("after add 2th element is " + linkedlist.get(2));
}

@Test
public void get() throws Exception {
assertEquals(9.9, linkedlist.get(1));
}

@Test
public void remove() throws Exception {
assertEquals(9.9, linkedlist.remove(1));
}

@Test
public void size() throws Exception {
assertEquals(2, linkedlist.size());

}

@Test
public void addFirst() throws Exception {
linkedlist.addFirst(3.3);
assertEquals(3.3, linkedlist.get(1));
// System.out.println();
}

@Test
public void addLast() throws Exception {
linkedlist.addLast(3.3);
assertEquals(3.3, linkedlist.get(linkedlist.size()));

}

@Test
public void removeFirst() throws Exception {
assertEquals(9.9, linkedlist.removeFirst());
}

@Test
public void removeLast() throws Exception {
assertEquals(9.99, linkedlist.removeLast());
}

}
58 changes: 58 additions & 0 deletions group16/2562124714/src/Test/QueueTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package Test;

import com.coding.basic.Queue;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import static org.junit.Assert.*;

/**
* Created by zhangwj on 2017/2/23.
*/
public class QueueTest {
private Queue queue = new Queue();
@Before
public void setUp() throws Exception {
System.out.println("初始化队列,元素为a,b,c,d");

String[] s = {"a", "b","c","d"};
for (String a:s
) {
queue.enQueue(a);
}

}

@After
public void tearDown() throws Exception {

}

@Test
public void enQueue() throws Exception {
queue.enQueue("dasdas");
assertEquals(5, queue.size());
// assertEquals("dasdas", queue.);
}

@Test
public void deQueue() throws Exception {
assertEquals("a",queue.deQueue());
assertEquals(3, queue.size());

}

@Test
public void isEmpty() throws Exception {
assertEquals(false, queue.isEmpty());

}

@Test
public void size() throws Exception {
assertEquals(4, queue.size());

}

}
Loading

0 comments on commit e3c7381

Please sign in to comment.