makefile + testing expanded

This commit is contained in:
2019-04-29 19:15:52 +02:00
parent 047a7ded1d
commit 1814b8208a
2 changed files with 42 additions and 0 deletions

16
tests/makefile Normal file
View File

@@ -0,0 +1,16 @@
CC = g++
CFLAGS = -std=c++17 -Wall
CPPS = $(wildcard *.cpp)
EXES = $(patsubst %.cpp, %.out, $(CPPS))
.PHONY: all clean
%.out: %.cpp
$(CC) $(CFLAGS) $< -o $@
all: $(EXES)
clean:
-rm *.o
-rm *.out

View File

@@ -1,6 +1,8 @@
#include <cstdio> #include <cstdio>
#include <exception> #include <exception>
#include <random> #include <random>
#include <string>
#include <vector>
namespace Util namespace Util
{ {
@@ -33,4 +35,28 @@ void Execute(bool (*testFunction)(void), char const * const message)
std::printf("[FAIL] Exception thrown during execution of <%s>, error: %s\n", message, e.what()); std::printf("[FAIL] Exception thrown during execution of <%s>, error: %s\n", message, e.what());
} }
} }
void Execute(bool (*testFunction)(std::vector<std::string> &), char const * const message)
{
std::vector<std::string> issues;
try
{
if(testFunction(issues))
{
std::printf("[PASS] %s\n", message);
}
else
{
for(auto & issue : issues)
{
std::printf(" Issue: %s\n", issue.c_str());
}
std::printf("[FAIL] %s\n", message);
}
}
catch(std::exception & e)
{
std::printf("[FAIL] Exception thrown during execution of <%s>, error: %s\n", message, e.what());
}
}
}; };