create stackApp, which includes convertion of number system, and parenthesis matching.
This commit is contained in:
33
thu_dsa/chp4/testStackApp.cpp
Normal file
33
thu_dsa/chp4/testStackApp.cpp
Normal file
@@ -0,0 +1,33 @@
|
||||
#include "../chp2/Fib.h"
|
||||
#include "stackApp.h"
|
||||
#include <iostream>
|
||||
#include <cassert>
|
||||
|
||||
using std::cout;
|
||||
using std::endl;
|
||||
|
||||
void test_convert();
|
||||
void test_paren();
|
||||
|
||||
int main(){
|
||||
cout << "Running tests......" << endl;
|
||||
test_convert();
|
||||
test_paren();
|
||||
|
||||
cout << "All tests passed." << endl;
|
||||
system("pause");
|
||||
return 0;
|
||||
}
|
||||
|
||||
void test_convert(){
|
||||
assert(strcmp(convert(1314, 16), "522") == 0);
|
||||
assert(strcmp(convert(520, 2), "1000001000") == 0);
|
||||
assert(strcmp(convert(520, 16), "208") == 0);
|
||||
}
|
||||
|
||||
void test_paren(){
|
||||
assert(paren("(())") == true);
|
||||
assert(paren("()()") == true);
|
||||
assert(paren("[(])") == false);
|
||||
assert(paren("{[()]{[({})]}}") == true);
|
||||
}
|
||||
Reference in New Issue
Block a user