54 lines
1.1 KiB
C++
54 lines
1.1 KiB
C++
#include "MutantStack.hpp"
|
|
|
|
#include <cstdlib>
|
|
#include <ctime>
|
|
|
|
int main(void) {
|
|
|
|
std::cout << "\n---Test0---\n" << std::endl;
|
|
|
|
{
|
|
MutantStack<int> mstack;
|
|
mstack.push(5);
|
|
mstack.push(17);
|
|
std::cout << mstack.top() << std::endl;
|
|
mstack.pop();
|
|
std::cout << mstack.size() << std::endl;
|
|
mstack.push(3);
|
|
mstack.push(5);
|
|
mstack.push(737);
|
|
mstack.push(0);
|
|
MutantStack<int>::iterator it = mstack.begin();
|
|
MutantStack<int>::iterator ite = mstack.end();
|
|
++it;
|
|
--it;
|
|
while (it != ite)
|
|
{
|
|
std::cout << *it << ", ";
|
|
++it;
|
|
}
|
|
}
|
|
|
|
std::cout << "\n\n---Test1---\n" << std::endl;
|
|
|
|
{
|
|
MutantStack<int> mstack;
|
|
srand(time(NULL));
|
|
for (int i = 0; i < 20; i++)
|
|
mstack.push((rand() % 200) - 100);
|
|
if (find(mstack.begin(), mstack.end(), 0) != mstack.end())
|
|
std::cout << "There is 0 in the stack" << std::endl;
|
|
else
|
|
std::cout << "There isn't 0 in the stack" << std::endl;
|
|
MutantStack<int>::iterator it = mstack.begin();
|
|
for (int i = 0; i < 20; i++) {
|
|
std::cout << *it << ", ";
|
|
it++;
|
|
}
|
|
}
|
|
|
|
std::cout << "\n\n---EndTest---\n" << std::endl;
|
|
|
|
return 0;
|
|
}
|