Stack added + found bugs squashed

This commit is contained in:
2019-05-07 19:43:31 +02:00
parent 3edd654f60
commit c1e498dfa0
6 changed files with 99 additions and 6 deletions

35
test/stack.cpp Normal file
View File

@@ -0,0 +1,35 @@
#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;
}