Stack added + found bugs squashed
This commit is contained in:
@@ -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
35
test/stack.cpp
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user