mirror of
https://github.com/TheAlgorithms/C-Plus-Plus.git
synced 2026-02-12 15:05:47 +08:00
cpp lint fixes and instantiate template classes
This commit is contained in:
@@ -1,56 +1,58 @@
|
||||
#include <iostream>
|
||||
#include "stack.cpp"
|
||||
#include "stack.h"
|
||||
|
||||
using namespace std;
|
||||
#include "./stack.h"
|
||||
|
||||
int main() {
|
||||
stack<int> stk;
|
||||
cout << "---------------------- Test construct ----------------------"
|
||||
<< endl;
|
||||
std::cout << "---------------------- Test construct ----------------------"
|
||||
<< std::endl;
|
||||
stk.display();
|
||||
cout << "---------------------- Test isEmptyStack ----------------------"
|
||||
<< endl;
|
||||
std::cout
|
||||
<< "---------------------- Test isEmptyStack ----------------------"
|
||||
<< std::endl;
|
||||
if (stk.isEmptyStack())
|
||||
cout << "PASS" << endl;
|
||||
std::cout << "PASS" << std::endl;
|
||||
else
|
||||
cout << "FAIL" << endl;
|
||||
cout << "---------------------- Test push ----------------------" << endl;
|
||||
cout << "After pushing 10 20 30 40 into stack: " << endl;
|
||||
std::cout << "FAIL" << std::endl;
|
||||
std::cout << "---------------------- Test push ----------------------"
|
||||
<< std::endl;
|
||||
std::cout << "After pushing 10 20 30 40 into stack: " << std::endl;
|
||||
stk.push(10);
|
||||
stk.push(20);
|
||||
stk.push(30);
|
||||
stk.push(40);
|
||||
stk.display();
|
||||
cout << "---------------------- Test top ----------------------" << endl;
|
||||
std::cout << "---------------------- Test top ----------------------"
|
||||
<< std::endl;
|
||||
int value = stk.top();
|
||||
if (value == 40)
|
||||
cout << "PASS" << endl;
|
||||
std::cout << "PASS" << std::endl;
|
||||
else
|
||||
cout << "FAIL" << endl;
|
||||
cout << "---------------------- Test pop ----------------------" << endl;
|
||||
std::cout << "FAIL" << std::endl;
|
||||
std::cout << "---------------------- Test pop ----------------------"
|
||||
<< std::endl;
|
||||
stk.display();
|
||||
stk.pop();
|
||||
stk.pop();
|
||||
cout << "After popping 2 times: " << endl;
|
||||
std::cout << "After popping 2 times: " << std::endl;
|
||||
stk.display();
|
||||
cout << "---------------------- Test overload = operator "
|
||||
"----------------------"
|
||||
<< endl;
|
||||
std::cout << "---------------------- Test overload = operator "
|
||||
"----------------------"
|
||||
<< std::endl;
|
||||
stack<int> stk1;
|
||||
cout << "stk current: " << endl;
|
||||
std::cout << "stk current: " << std::endl;
|
||||
stk.display();
|
||||
cout << endl << "Assign stk1 = stk " << endl;
|
||||
std::cout << std::endl << "Assign stk1 = stk " << std::endl;
|
||||
stk1 = stk;
|
||||
stk1.display();
|
||||
cout << endl << "After pushing 8 9 10 into stk1:" << endl;
|
||||
std::cout << std::endl << "After pushing 8 9 10 into stk1:" << std::endl;
|
||||
stk1.push(8);
|
||||
stk1.push(9);
|
||||
stk1.push(10);
|
||||
stk1.display();
|
||||
cout << endl << "stk current: " << endl;
|
||||
std::cout << std::endl << "stk current: " << std::endl;
|
||||
stk.display();
|
||||
cout << "Assign back stk = stk1:" << endl;
|
||||
std::cout << "Assign back stk = stk1:" << std::endl;
|
||||
stk = stk1;
|
||||
stk.display();
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user