-
Notifications
You must be signed in to change notification settings - Fork 33
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
1 parent
69453e7
commit 065cc45
Showing
3 changed files
with
75 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
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
44 changes: 44 additions & 0 deletions
44
test/com/deepak/ctci/Ch03_Stacks_And_Queues/Problem_05_Test.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,44 @@ | ||
/** | ||
* Cracking-The-Coding-Interview | ||
* Problem_04_Test.java | ||
*/ | ||
package com.deepak.ctci.Ch03_Stacks_And_Queues; | ||
|
||
import java.util.Stack; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
/** | ||
* Test cases for Problem 05 | ||
* | ||
* @author Deepak | ||
*/ | ||
public class Problem_05_Test { | ||
|
||
/** | ||
* Test cases for sorting a stack | ||
*/ | ||
@Test | ||
public void testSortStack() { | ||
Stack<Integer> input = new Stack<>(); | ||
input.push(2); | ||
input.push(9); | ||
input.push(7); | ||
input.push(3); | ||
input.push(1); | ||
input.push(5); | ||
input.push(10); | ||
Assert.assertTrue(input.size() == 7); | ||
Stack<Integer> output = Problem_05.sortStack(input); | ||
Assert.assertTrue(output.pop() == 10); | ||
Assert.assertTrue(output.pop() == 9); | ||
Assert.assertTrue(output.pop() == 7); | ||
Assert.assertTrue(output.pop() == 5); | ||
Assert.assertTrue(output.pop() == 3); | ||
Assert.assertTrue(output.pop() == 2); | ||
Assert.assertTrue(output.pop() == 1); | ||
Assert.assertTrue(output.size() == 0); | ||
} | ||
|
||
} |