-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
86 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ backend.log | |
# macOS products | ||
**/*.dSYM/ | ||
*_result_generation | ||
.DS_store | ||
|
||
build/ | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#pragma once | ||
|
||
#include <iostream> | ||
#include <string> | ||
#include <sstream> | ||
|
||
#include "types.hpp" | ||
|
||
#define ASCII_BACKGROUND_GREEN "\u001b[42m" | ||
#define ASCII_BACKGROUND_YELLOW "\u001b[43m" | ||
#define ASCII_BACKGROUND_RED "\u001b[41m" | ||
#define ASCII_BACKGROUND_MAGENTA "\u001b[45;1m" | ||
#define ASCII_RED "\033[1m\033[31m" | ||
#define ASCII_GREEN "\033[1m\033[32m" | ||
#define ASCII_GRAY "\u001b[38;5;243m" | ||
#define ASCII_BLACK "\u001b[38;5;232m" | ||
#define ASCII_BOLD "\u001b[1m" | ||
#define ASCII_RESET "\033[0m" | ||
|
||
namespace cest | ||
{ | ||
void showHelp(std::string binary) | ||
{ | ||
std::cout << "usage: " << binary << " [options]" << std::endl | ||
<< std::endl; | ||
std::cout << "Command line options:" << std::endl; | ||
std::cout << " -r/--randomize: Randomize test executions" << std::endl; | ||
std::cout << " -s/--seed <seed>: Inject seed for randomization uses (unsigned integer)"; | ||
std::cout << std::endl; | ||
} | ||
|
||
void printTestResult(TestCase *test_case, const std::stringstream & assertion_failures) | ||
{ | ||
if (test_case->test_failed) | ||
{ | ||
std::cout << ASCII_BACKGROUND_RED << ASCII_BLACK << ASCII_BOLD << " FAIL " << ASCII_RESET; | ||
} | ||
else if (test_case->skip) | ||
{ | ||
std::cout << ASCII_BACKGROUND_YELLOW << ASCII_BLACK << ASCII_BOLD << " SKIP " << ASCII_RESET; | ||
} | ||
else | ||
{ | ||
std::cout << ASCII_BACKGROUND_GREEN << ASCII_BLACK << ASCII_BOLD << " PASS " << ASCII_RESET; | ||
} | ||
|
||
std::cout << ASCII_GRAY << " " << test_case->file << ":" << test_case->line << ASCII_RESET << ASCII_BOLD << " it " << test_case->name << ASCII_RESET << std::endl; | ||
|
||
std::cout << assertion_failures.str(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#pragma once | ||
|
||
#include <functional> | ||
#include <string> | ||
|
||
namespace cest | ||
{ | ||
struct TestCase | ||
{ | ||
std::string name; | ||
std::string file; | ||
int line; | ||
std::function<void()> test; | ||
bool test_failed; | ||
bool forced_pass; | ||
bool skip; | ||
bool fit; | ||
std::string failure_message; | ||
|
||
TestCase() : test_failed(false), forced_pass(false), skip(false) | ||
{ | ||
} | ||
}; | ||
|
||
struct TestSuite | ||
{ | ||
std::vector<cest::TestCase *> test_cases; | ||
std::string test_suite_name; | ||
}; | ||
} |