Commit fa96d939 authored by michael lundquist's avatar michael lundquist
Browse files

Spiffing up the test methods with random numbers and deleting some unnecessary prints

parent 797edb9b
package com.ds.fifthassignment; package com.ds.fifthassignment;
import java.util.Stack; import com.ds.fifthassignment.Stack;
public class Application { public class Application {
public class Bracket { public class Bracket {
...@@ -18,7 +18,7 @@ public class Application { ...@@ -18,7 +18,7 @@ public class Application {
public static void main(String[] args) { public static void main(String[] args) {
char[] input1 = input1 = "[(4+5+1) x (4 / 2)]".toCharArray(); char[] input1 = "[(4+5+1) x (4 / 2)]".toCharArray();
char[] input2 = "[(4+5+1) x (4 / 2]".toCharArray(); char[] input2 = "[(4+5+1) x (4 / 2]".toCharArray();
System.out.println(isValid(input1)); System.out.println(isValid(input1));
System.out.println(isValid(input2)); System.out.println(isValid(input2));
...@@ -32,7 +32,7 @@ public class Application { ...@@ -32,7 +32,7 @@ public class Application {
*/ */
//TODO: test this //TODO: test this
public static boolean isValid(char[] input) { public static boolean isValid(char[] input) {
Stack s = new Stack(); Stack s = new Stack();
for (char c: input){ for (char c: input){
if( Bracket.RIGHT.indexOf(c) != -1 ){ if( Bracket.RIGHT.indexOf(c) != -1 ){
......
...@@ -83,9 +83,7 @@ public class AppTest ...@@ -83,9 +83,7 @@ public class AppTest
*/ */
@Test @Test
public void test_LL_StackSearch(){ public void test_LL_StackSearch(){
//Integer test = randRange(1,10); Integer test = randRange(1,10);
int test = 4;
JOptionPane.showMessageDialog(null, "hi" );
LinkedListStack s = new LinkedListStack(); LinkedListStack s = new LinkedListStack();
for(int k = 1; k<=10; k++){ for(int k = 1; k<=10; k++){
...@@ -95,8 +93,8 @@ public class AppTest ...@@ -95,8 +93,8 @@ public class AppTest
s.push("a"); s.push("a");
} }
} }
JOptionPane.showMessageDialog(null, "the value of test is: " + (11 - test) ); //JOptionPane.showMessageDialog(null, "the value of test is: " + (11 - test) );
JOptionPane.showMessageDialog(null, "The search result: " + s.search("b")); //JOptionPane.showMessageDialog(null, "The search result: " + s.search("b"));
assertTrue(s.search("b") == (11 - test)); assertTrue(s.search("b") == (11 - test));
//assertTrue(false); //assertTrue(false);
} }
...@@ -106,9 +104,8 @@ public class AppTest ...@@ -106,9 +104,8 @@ public class AppTest
*/ */
@Test @Test
public void testArrayStackSearch(){ public void testArrayStackSearch(){
//Integer test = randRange(1,10); Integer test = randRange(1,10);
int test = 4;
JOptionPane.showMessageDialog(null, "hi" );
ArrayStack s = new ArrayStack(); ArrayStack s = new ArrayStack();
for(int k = 1; k<=10; k++){ for(int k = 1; k<=10; k++){
...@@ -118,9 +115,9 @@ public class AppTest ...@@ -118,9 +115,9 @@ public class AppTest
s.push("a"); s.push("a");
} }
} }
JOptionPane.showMessageDialog(null, "the value of test is: " + (11 - test) ); //JOptionPane.showMessageDialog(null, "the value of test is: " + (11 - test) );
int ser = s.search("b"); int ser = s.search("b");
JOptionPane.showMessageDialog(null, "The search result: " + ser); //JOptionPane.showMessageDialog(null, "The search result: " + ser);
assertTrue(ser == (11 - test)); assertTrue(ser == (11 - test));
//assertTrue(false); //assertTrue(false);
} }
...@@ -130,6 +127,12 @@ public class AppTest ...@@ -130,6 +127,12 @@ public class AppTest
*/ */
@Test @Test
public void testQueueElement(){ public void testQueueElement(){
Integer test = randRange(1,10);
ArrayStack s = new ArrayStack();
for(int k = 1; k<=10; k++){
s.push("a");
}
s.push("b");
assertTrue(true); assertTrue(true);
} }
...@@ -138,6 +141,12 @@ public class AppTest ...@@ -138,6 +141,12 @@ public class AppTest
*/ */
@Test @Test
public void test_LL_QueueElement(){ public void test_LL_QueueElement(){
Integer test = randRange(1,10);
LinkedListQueue q = new LinkedListQueue();
for(int k = 1; k<=10; k++){
q.push("a");
}
q.push("b");
assertTrue(true); assertTrue(true);
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment