Files
datastructures/test/stack.cpp

35 lines
613 B
C++

#include "../src/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;
}