add toPostfix function(in stackApp.cpp). Create Queue.h, and passed all tests.
This commit is contained in:
@@ -9,12 +9,14 @@ using std::endl;
|
||||
void test_convert();
|
||||
void test_paren();
|
||||
void test_evaluate();
|
||||
void test_toPostfix();
|
||||
|
||||
int main(){
|
||||
int stackApp_test_main(){
|
||||
cout << "Running tests......" << endl;
|
||||
test_convert();
|
||||
test_paren();
|
||||
test_evaluate();
|
||||
test_toPostfix();
|
||||
|
||||
cout << "All tests passed." << endl;
|
||||
system("pause");
|
||||
@@ -38,3 +40,7 @@ void test_evaluate(){
|
||||
assert(evaluate("2*5+(3+4-2*7)/2") == 6.5);
|
||||
assert(evaluate("(0!+ 1) * 2 ^ (3!+ 4) - (5!- 67 - (8 + 9))") == 2012);
|
||||
}
|
||||
|
||||
void test_toPostfix(){
|
||||
assert(strcmp(toPostfix("(0! + 1) ^ (2 * 3! + 4 - 5)"),"0!1+23!*4+5-^") == 0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user