Improvements for markdown parsing.

This commit is contained in:
James Grogan 2022-12-06 18:02:43 +00:00
parent fc44290e3f
commit 8705859115
40 changed files with 957 additions and 537 deletions

View file

@ -36,17 +36,30 @@ void TestCaseRunner::markTestFailure(const std::string& line)
sFailureLine = line;
}
bool TestCaseRunner::run()
bool TestCaseRunner::run(const std::vector<std::string>& args)
{
std::string test_to_run;
if (args.size() > 0 )
{
test_to_run = args[0];
}
FileLogger::GetInstance().disable();
for (auto test_case : mCases)
{
if (!test_to_run.empty())
{
if (test_case->getName() != test_to_run)
{
continue;
}
}
sLastTestFailed = false;
std::cout << "TestFramework: Running Test - " << test_case->getName() << std::endl;
test_case->run();
if (sLastTestFailed)
{
std::cout << "Failed at line: " << sLastTestFailed << std::endl;
std::cout << "Failed at line: " << sFailureLine << std::endl;
mFailingTests.push_back(test_case->getName());
}
}

View file

@ -18,7 +18,7 @@ public:
void markTestFailure(const std::string& line);
bool run();
bool run(const std::vector<std::string>& args);
private:
std::vector<std::string> mFailingTests;

View file

@ -16,12 +16,12 @@ struct Holder
static void Test##NAME() \
#define REQUIRE(predicate) \
if(!predicate) \
{ \
TestCaseRunner::getInstance().markTestFailure(std::to_string(__LINE__)); \
return; \
} \
#define REQUIRE(predicate) \
if(!bool(predicate)) \
{ \
TestCaseRunner::getInstance().markTestFailure(std::to_string(__LINE__) + " with check: '" + std::string(#predicate) + "'"); \
return; \
} \

View file

@ -7,9 +7,17 @@ using Path = std::filesystem::path;
class TestUtils
{
public:
static Path getTestOutputDir()
static Path getTestOutputDir(const std::string& testFileName = {})
{
return std::filesystem::current_path() / "test_output";
if (!testFileName.empty())
{
const auto name = Path(testFileName).filename().stem();
return std::filesystem::current_path() / "test_output" / name;
}
else
{
return std::filesystem::current_path() / "test_output";
}
}
static Path getTestDataDir()