35 lines
522 B
C++
35 lines
522 B
C++
#include "../sequential/stack.hpp"
|
|
#include "testutil.hpp"
|
|
#include <stack>
|
|
|
|
bool TestStack()
|
|
{
|
|
std::size_t testSize = 512ul;
|
|
|
|
std::stack<unsigned> truth;
|
|
Stack<unsigned> stack;
|
|
|
|
for(std::size_t i = 0; i < testSize; ++i)
|
|
{
|
|
unsigned const toInsert = Util::GetRandomNumber();
|
|
truth.push(toInsert);
|
|
stack.Push(toInsert);
|
|
}
|
|
|
|
while(!truth.empty())
|
|
{
|
|
if(truth.top() != stack.Pop())
|
|
{
|
|
return false;
|
|
}
|
|
truth.pop();
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
int main()
|
|
{
|
|
Test::Execute(TestStack, "Pop push test");
|
|
return 0;
|
|
} |