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

View File

@@ -4,7 +4,7 @@ CFLAGS = -std=c++17 -Wall -g
CPPS = $(wildcard *.cpp)
EXES = $(patsubst %.cpp, %.out, $(CPPS))
.PHONY: all clean rebuild
.PHONY: all clean rebuild check
%.out: %.cpp
$(CC) $(CFLAGS) $< -o $@
@@ -15,4 +15,9 @@ clean:
-rm *.o
-rm *.out
rebuild: clean all
rebuild: clean all
EXESQUOTED = $(patsubst %, "%", $(EXES))
check: all
./execute-all.sh

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;
}