Merge pull request #102 from adbridge/utest_namespace

Added full namespacing to instances of status_t to prevent namespace
Marcus Shawcroft 2016-05-18 09:32:25 +01:00
commit c24e3e4178
5 changed files with 30 additions and 30 deletions

View File

@ -46,7 +46,7 @@ static void test_failure_handler(const failure_t failure) {
} }
// --- VERBOSE TEST HANDLERS --- // --- VERBOSE TEST HANDLERS ---
status_t utest::v1::verbose_test_setup_handler(const size_t number_of_cases) utest::v1::status_t utest::v1::verbose_test_setup_handler(const size_t number_of_cases)
{ {
UTEST_LOG_FUNCTION UTEST_LOG_FUNCTION
printf(">>> Running %u test cases...\n", number_of_cases); printf(">>> Running %u test cases...\n", number_of_cases);
@ -72,14 +72,14 @@ void utest::v1::verbose_test_failure_handler(const failure_t failure)
} }
// --- VERBOSE CASE HANDLERS --- // --- VERBOSE CASE HANDLERS ---
status_t utest::v1::verbose_case_setup_handler(const Case *const source, const size_t index_of_case) utest::v1::status_t utest::v1::verbose_case_setup_handler(const Case *const source, const size_t index_of_case)
{ {
UTEST_LOG_FUNCTION UTEST_LOG_FUNCTION
printf("\n>>> Running case #%u: '%s'...\n", index_of_case + 1, source->get_description()); printf("\n>>> Running case #%u: '%s'...\n", index_of_case + 1, source->get_description());
return STATUS_CONTINUE; return STATUS_CONTINUE;
} }
status_t utest::v1::verbose_case_teardown_handler(const Case *const source, const size_t passed, const size_t failed, const failure_t failure) utest::v1::status_t utest::v1::verbose_case_teardown_handler(const Case *const source, const size_t passed, const size_t failed, const failure_t failure)
{ {
UTEST_LOG_FUNCTION UTEST_LOG_FUNCTION
printf(">>> '%s': %u passed, %u failed", source->get_description(), passed, failed); printf(">>> '%s': %u passed, %u failed", source->get_description(), passed, failed);
@ -91,7 +91,7 @@ status_t utest::v1::verbose_case_teardown_handler(const Case *const source, cons
return STATUS_CONTINUE; return STATUS_CONTINUE;
} }
status_t utest::v1::verbose_case_failure_handler(const Case *const /*source*/, const failure_t failure) utest::v1::status_t utest::v1::verbose_case_failure_handler(const Case *const /*source*/, const failure_t failure)
{ {
UTEST_LOG_FUNCTION UTEST_LOG_FUNCTION
if (!(failure.reason & REASON_ASSERTION)) { if (!(failure.reason & REASON_ASSERTION)) {

View File

@ -23,7 +23,7 @@
using namespace utest::v1; using namespace utest::v1;
static status_t unknown_test_setup_handler(const size_t); static utest::v1::status_t unknown_test_setup_handler(const size_t);
static void selftest_failure_handler(const failure_t); static void selftest_failure_handler(const failure_t);
static void test_failure_handler(const failure_t); static void test_failure_handler(const failure_t);
@ -57,7 +57,7 @@ const handlers_t utest::v1::selftest_handlers = {
// --- SPECIAL HANDLERS --- // --- SPECIAL HANDLERS ---
static status_t unknown_test_setup_handler(const size_t) { static utest::v1::status_t unknown_test_setup_handler(const size_t) {
UTEST_LOG_FUNCTION UTEST_LOG_FUNCTION
printf(">>> I do not know how to tell greentea that the test started, since\n"); printf(">>> I do not know how to tell greentea that the test started, since\n");
printf(">>> you forgot to override the `test_setup_handler` in your specification.\n"); printf(">>> you forgot to override the `test_setup_handler` in your specification.\n");
@ -87,7 +87,7 @@ static void test_failure_handler(const failure_t failure) {
} }
// --- GREENTEA HANDLERS --- // --- GREENTEA HANDLERS ---
status_t utest::v1::greentea_test_setup_handler(const size_t number_of_cases) utest::v1::status_t utest::v1::greentea_test_setup_handler(const size_t number_of_cases)
{ {
UTEST_LOG_FUNCTION UTEST_LOG_FUNCTION
greentea_send_kv(TEST_ENV_TESTCASE_COUNT, number_of_cases); greentea_send_kv(TEST_ENV_TESTCASE_COUNT, number_of_cases);
@ -110,29 +110,29 @@ void utest::v1::greentea_test_failure_handler(const failure_t failure)
} }
// --- GREENTEA CASE HANDLERS --- // --- GREENTEA CASE HANDLERS ---
status_t utest::v1::greentea_case_setup_handler(const Case *const source, const size_t index_of_case) utest::v1::status_t utest::v1::greentea_case_setup_handler(const Case *const source, const size_t index_of_case)
{ {
UTEST_LOG_FUNCTION UTEST_LOG_FUNCTION
status_t status = verbose_case_setup_handler(source, index_of_case); utest::v1::status_t status = verbose_case_setup_handler(source, index_of_case);
greentea_send_kv(TEST_ENV_TESTCASE_START, source->get_description()); greentea_send_kv(TEST_ENV_TESTCASE_START, source->get_description());
return status; return status;
} }
status_t utest::v1::greentea_case_teardown_handler(const Case *const source, const size_t passed, const size_t failed, const failure_t failure) utest::v1::status_t utest::v1::greentea_case_teardown_handler(const Case *const source, const size_t passed, const size_t failed, const failure_t failure)
{ {
UTEST_LOG_FUNCTION UTEST_LOG_FUNCTION
greentea_send_kv(TEST_ENV_TESTCASE_FINISH, source->get_description(), passed, failed); greentea_send_kv(TEST_ENV_TESTCASE_FINISH, source->get_description(), passed, failed);
return verbose_case_teardown_handler(source, passed, failed, failure); return verbose_case_teardown_handler(source, passed, failed, failure);
} }
status_t utest::v1::greentea_case_failure_abort_handler(const Case *const source, const failure_t failure) utest::v1::status_t utest::v1::greentea_case_failure_abort_handler(const Case *const source, const failure_t failure)
{ {
UTEST_LOG_FUNCTION UTEST_LOG_FUNCTION
status_t status = verbose_case_failure_handler(source, failure); utest::v1::status_t status = verbose_case_failure_handler(source, failure);
return (status == STATUS_IGNORE) ? STATUS_IGNORE : STATUS_ABORT; return (status == STATUS_IGNORE) ? STATUS_IGNORE : STATUS_ABORT;
} }
status_t utest::v1::greentea_case_failure_continue_handler(const Case *const source, const failure_t failure) utest::v1::status_t utest::v1::greentea_case_failure_continue_handler(const Case *const source, const failure_t failure)
{ {
UTEST_LOG_FUNCTION UTEST_LOG_FUNCTION
return verbose_case_failure_handler(source, failure); return verbose_case_failure_handler(source, failure);

View File

@ -154,7 +154,7 @@ void Harness::raise_failure(const failure_reason_t reason)
// this allows using unity assertion macros without setting up utest. // this allows using unity assertion macros without setting up utest.
if (test_cases == NULL) return; if (test_cases == NULL) return;
status_t fail_status = STATUS_ABORT; utest::v1::status_t fail_status = STATUS_ABORT;
{ {
UTEST_ENTER_CRITICAL_SECTION; UTEST_ENTER_CRITICAL_SECTION;
@ -175,7 +175,7 @@ void Harness::raise_failure(const failure_reason_t reason)
location_t fail_loc(location); location_t fail_loc(location);
location = LOCATION_CASE_TEARDOWN; location = LOCATION_CASE_TEARDOWN;
status_t teardown_status = handlers.case_teardown(case_current, case_passed, case_failed, failure_t(reason, fail_loc)); utest::v1::status_t teardown_status = handlers.case_teardown(case_current, case_passed, case_failed, failure_t(reason, fail_loc));
if (teardown_status < STATUS_CONTINUE) raise_failure(REASON_CASE_TEARDOWN); if (teardown_status < STATUS_CONTINUE) raise_failure(REASON_CASE_TEARDOWN);
else if (teardown_status > signed(test_length)) raise_failure(REASON_CASE_INDEX); else if (teardown_status > signed(test_length)) raise_failure(REASON_CASE_INDEX);
else if (teardown_status >= 0) case_index = teardown_status - 1; else if (teardown_status >= 0) case_index = teardown_status - 1;
@ -205,7 +205,7 @@ void Harness::schedule_next_case()
if (handlers.case_teardown) { if (handlers.case_teardown) {
// printf("Schedule next case: case_passed = %d, case_failed = %d\n", case_passed, case_failed); // printf("Schedule next case: case_passed = %d, case_failed = %d\n", case_passed, case_failed);
status_t status = handlers.case_teardown(case_current, case_passed, case_failed, utest::v1::status_t status = handlers.case_teardown(case_current, case_passed, case_failed,
case_failed ? failure_t(REASON_CASES, LOCATION_UNKNOWN) : failure_t(REASON_NONE)); case_failed ? failure_t(REASON_CASES, LOCATION_UNKNOWN) : failure_t(REASON_NONE));
if (status < STATUS_CONTINUE) raise_failure(REASON_CASE_TEARDOWN); if (status < STATUS_CONTINUE) raise_failure(REASON_CASE_TEARDOWN);
else if (status > signed(test_length)) raise_failure(REASON_CASE_INDEX); else if (status > signed(test_length)) raise_failure(REASON_CASE_INDEX);

View File

@ -126,34 +126,34 @@ namespace v1 {
}; };
/// Prints the number of tests to run and continues. /// Prints the number of tests to run and continues.
status_t verbose_test_setup_handler (const size_t number_of_cases); utest::v1::status_t verbose_test_setup_handler (const size_t number_of_cases);
/// Prints the number of tests that passed and failed with a reason if provided. /// Prints the number of tests that passed and failed with a reason if provided.
void verbose_test_teardown_handler(const size_t passed, const size_t failed, const failure_t failure); void verbose_test_teardown_handler(const size_t passed, const size_t failed, const failure_t failure);
/// Prints the failure for `REASON_TEST_SETUP` and `REASON_TEST_TEARDOWN` and then dies. /// Prints the failure for `REASON_TEST_SETUP` and `REASON_TEST_TEARDOWN` and then dies.
void verbose_test_failure_handler (const failure_t failure); void verbose_test_failure_handler (const failure_t failure);
/// Prints the index and description of the case being run and continues. /// Prints the index and description of the case being run and continues.
status_t verbose_case_setup_handler (const Case *const source, const size_t index_of_case); utest::v1::status_t verbose_case_setup_handler (const Case *const source, const size_t index_of_case);
/// Prints the number of tests that passed and failed with a reason if provided within this case and continues. /// Prints the number of tests that passed and failed with a reason if provided within this case and continues.
status_t verbose_case_teardown_handler(const Case *const source, const size_t passed, const size_t failed, const failure_t failure); utest::v1::status_t verbose_case_teardown_handler(const Case *const source, const size_t passed, const size_t failed, const failure_t failure);
/// Prints the reason of the failure and continues, unless the teardown handler failed, for which it aborts. /// Prints the reason of the failure and continues, unless the teardown handler failed, for which it aborts.
status_t verbose_case_failure_handler (const Case *const source, const failure_t reason); utest::v1::status_t verbose_case_failure_handler (const Case *const source, const failure_t reason);
/// Requests the start test case from greentea and continues. /// Requests the start test case from greentea and continues.
status_t greentea_test_setup_handler (const size_t number_of_cases); utest::v1::status_t greentea_test_setup_handler (const size_t number_of_cases);
/// Reports the test results to greentea. /// Reports the test results to greentea.
void greentea_test_teardown_handler(const size_t passed, const size_t failed, const failure_t failure); void greentea_test_teardown_handler(const size_t passed, const size_t failed, const failure_t failure);
/// Reports the failure for `REASON_TEST_SETUP` and `REASON_TEST_TEARDOWN` to greentea and then dies. /// Reports the failure for `REASON_TEST_SETUP` and `REASON_TEST_TEARDOWN` to greentea and then dies.
void greentea_test_failure_handler (const failure_t failure); void greentea_test_failure_handler (const failure_t failure);
/// Registers the test case setup with greentea. /// Registers the test case setup with greentea.
status_t greentea_case_setup_handler (const Case *const source, const size_t index_of_case); utest::v1::status_t greentea_case_setup_handler (const Case *const source, const size_t index_of_case);
/// Registers the test case teardown with greentea. /// Registers the test case teardown with greentea.
status_t greentea_case_teardown_handler(const Case *const source, const size_t passed, const size_t failed, const failure_t failure); utest::v1::status_t greentea_case_teardown_handler(const Case *const source, const size_t passed, const size_t failed, const failure_t failure);
/// Reports the failure to greentea and then aborts. /// Reports the failure to greentea and then aborts.
status_t greentea_case_failure_abort_handler (const Case *const source, const failure_t reason); utest::v1::status_t greentea_case_failure_abort_handler (const Case *const source, const failure_t reason);
/// Reports the failure to greentea and then continues. /// Reports the failure to greentea and then continues.
status_t greentea_case_failure_continue_handler(const Case *const source, const failure_t reason); utest::v1::status_t greentea_case_failure_continue_handler(const Case *const source, const failure_t reason);
/// The verbose default handlers that always continue on failure /// The verbose default handlers that always continue on failure
extern const handlers_t verbose_continue_handlers; extern const handlers_t verbose_continue_handlers;

View File

@ -111,7 +111,7 @@ namespace v1 {
/// Stringifies a location. /// Stringifies a location.
const char* stringify(location_t location); const char* stringify(location_t location);
/// Stringifies a status. /// Stringifies a status.
const char* stringify(status_t status); const char* stringify(utest::v1::status_t status);
/** Control class for specifying test case attributes /** Control class for specifying test case attributes
* *
@ -231,7 +231,7 @@ namespace v1 {
* You can return `STATUS_ABORT` if you initialization failed and the test teardown handler will * You can return `STATUS_ABORT` if you initialization failed and the test teardown handler will
* then be called with the `REASON_SETUP`. * then be called with the `REASON_SETUP`.
*/ */
typedef status_t (*test_setup_handler_t)(const size_t number_of_cases); typedef utest::v1::status_t (*test_setup_handler_t)(const size_t number_of_cases);
/** Test teardown handler. /** Test teardown handler.
* *
@ -270,7 +270,7 @@ namespace v1 {
* failure handler with `REASON_SETUP` and then the case teardown handler with `REASON_SETUP`. * failure handler with `REASON_SETUP` and then the case teardown handler with `REASON_SETUP`.
* This gives the teardown handler a chance to clean up a failed setup. * This gives the teardown handler a chance to clean up a failed setup.
*/ */
typedef status_t (*case_setup_handler_t)(const Case *const source, const size_t index_of_case); typedef utest::v1::status_t (*case_setup_handler_t)(const Case *const source, const size_t index_of_case);
/** Primitive test case handler /** Primitive test case handler
* *
@ -316,7 +316,7 @@ namespace v1 {
* You can return `STATUS_ABORT` to indicate that your teardown failed, which will call the case * You can return `STATUS_ABORT` to indicate that your teardown failed, which will call the case
* failure handler with `REASON_TEARDOWN`. * failure handler with `REASON_TEARDOWN`.
*/ */
typedef status_t (*case_teardown_handler_t)(const Case *const source, const size_t passed, const size_t failed, const failure_t reason); typedef utest::v1::status_t (*case_teardown_handler_t)(const Case *const source, const size_t passed, const size_t failed, const failure_t reason);
/** Test case failure handler. /** Test case failure handler.
* *
@ -330,7 +330,7 @@ namespace v1 {
* teardown handler with reason. If a failure occurs during teardown, the teardown will not be called again. * teardown handler with reason. If a failure occurs during teardown, the teardown will not be called again.
* You may return `STATUS_IGNORE` which will cause the harness to ignore and not count the failure. * You may return `STATUS_IGNORE` which will cause the harness to ignore and not count the failure.
*/ */
typedef status_t (*case_failure_handler_t)(const Case *const source, const failure_t reason); typedef utest::v1::status_t (*case_failure_handler_t)(const Case *const source, const failure_t reason);
// deprecations // deprecations