This commit is contained in:
navid.sassan 2020-09-21 19:53:10 +02:00
parent d7fd2e8bdd
commit a9e1eaa7f5
3 changed files with 105 additions and 105 deletions

View File

@ -1,29 +1,29 @@
package ch.zhaw.ads; package ch.zhaw.ads;
import org.junit.Test; import org.junit.Test;
import org.junit.Before; import org.junit.Before;
import static org.junit.Assert.*; import static org.junit.Assert.*;
public class BracketServerTest { public class BracketServerTest {
/* BracketServer bs; /* BracketServer bs;
@Before @Before
public void setUp() throws Exception { public void setUp() throws Exception {
bs = new BracketServer(); bs = new BracketServer();
} }
private void test(String s, boolean b) { private void test(String s, boolean b) {
assertEquals(s,bs.checkBrackets(s),b); assertEquals(s,bs.checkBrackets(s),b);
} }
@Test @Test
public void testBracket() { public void testBracket() {
test("()",true); test("()",true);
test("(()]",false); test("(()]",false);
test("((([([])])))",true); test("((([([])])))",true);
test("[(])",false); test("[(])",false);
test("[(3 +3)* 35 +3]* {3 +2}",true); test("[(3 +3)* 35 +3]* {3 +2}",true);
test("[({3 +3)* 35} +3]* {3 +2}",false); test("[({3 +3)* 35} +3]* {3 +2}",false);
} }
*/ */
} }

View File

@ -1,23 +1,23 @@
package ch.zhaw.ads; package ch.zhaw.ads;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import static org.junit.Assert.*; import static org.junit.Assert.*;
public class KgvServerTest { public class KgvServerTest {
KGVServer server; KGVServer server;
@Before @Before
public void setUp() throws Exception { public void setUp() throws Exception {
server = new KGVServer(); server = new KGVServer();
} }
@Test @Test
public void testKgv() { public void testKgv() {
assertEquals(server.kgv(3,4),12); assertEquals(server.kgv(3,4),12);
assertEquals(server.kgv(2,4),4); assertEquals(server.kgv(2,4),4);
assertEquals(server.kgv(5,7),35); assertEquals(server.kgv(5,7),35);
assertEquals(server.kgv(4,6),12); assertEquals(server.kgv(4,6),12);
} }
} }

View File

@ -1,58 +1,58 @@
/** /**
* @(#)StackTest.java * @(#)StackTest.java
* *
* *
* @author * @author
* @version 1.00 2017/8/30 * @version 1.00 2017/8/30
*/ */
package ch.zhaw.ads; package ch.zhaw.ads;
import org.junit.Test; import org.junit.Test;
import org.junit.Before; import org.junit.Before;
import static org.junit.Assert.*; import static org.junit.Assert.*;
public class StackTest { public class StackTest {
ListStack stack; ListStack stack;
@Before @Before
public void setUp() throws Exception { public void setUp() throws Exception {
stack = new ListStack(); stack = new ListStack();
} }
@Test @Test
public void testPush1() { public void testPush1() {
stack.push("A"); stack.push("A");
Object o = stack.pop(); Object o = stack.pop();
assertEquals(o, "A"); assertEquals(o, "A");
} }
@Test @Test
public void testPush2() { public void testPush2() {
stack.push("A"); stack.push("A");
stack.push("B"); stack.push("B");
assertEquals(stack.pop(), "B"); assertEquals(stack.pop(), "B");
assertEquals(stack.pop(), "A"); assertEquals(stack.pop(), "A");
} }
@Test @Test
public void testIsEmpty() { public void testIsEmpty() {
assertTrue(stack.isEmpty()); assertTrue(stack.isEmpty());
stack.push("A"); stack.push("A");
assertFalse(stack.isEmpty()); assertFalse(stack.isEmpty());
stack.pop(); stack.pop();
assertTrue(stack.isEmpty()); assertTrue(stack.isEmpty());
} }
@Test @Test
public void testIsFull() { public void testIsFull() {
assertFalse(stack.isFull()); assertFalse(stack.isFull());
} }
@Test @Test
public void testEmptyPop() { public void testEmptyPop() {
assertEquals(stack.pop(), null); assertEquals(stack.pop(), null);
} }
} }