Replace `repeat_count` with `call_count`.

This aims to reduce confusion over repeat vs. call counting, and
the resulting off-by-one error due to different user expectations.
Niklas Hauser 2015-12-21 15:35:28 +00:00 committed by Martin Kojtal
parent 15f3ccad1b
commit d5c8b80e73
5 changed files with 19 additions and 18 deletions

View File

@ -103,7 +103,7 @@ Case::Case(const char *description,
// control flow handler
Case::Case(const char *description,
const case_setup_handler_t setup_handler,
const case_repeat_count_handler_t case_repeat_count_handler,
const case_call_count_handler_t case_repeat_count_handler,
const case_teardown_handler_t teardown_handler,
const case_failure_handler_t failure_handler) :
description(description),
@ -116,7 +116,7 @@ Case::Case(const char *description,
{}
Case::Case(const char *description,
const case_repeat_count_handler_t case_repeat_count_handler,
const case_call_count_handler_t case_repeat_count_handler,
const case_failure_handler_t failure_handler) :
description(description),
handler(ignore_handler),
@ -128,7 +128,7 @@ Case::Case(const char *description,
{}
Case::Case(const char *description,
const case_repeat_count_handler_t case_repeat_count_handler,
const case_call_count_handler_t case_repeat_count_handler,
const case_teardown_handler_t teardown_handler,
const case_failure_handler_t failure_handler) :
description(description),

View File

@ -34,7 +34,7 @@ namespace
const Case *case_current = NULL;
control_t case_control = control_t(REPEAT_SETUP_TEARDOWN);
size_t case_repeat_count = 0;
size_t case_repeat_count = 1;
minar::callback_handle_t case_timeout_handle = NULL;
size_t case_validation_count = 0;
@ -150,7 +150,7 @@ void Harness::schedule_next_case()
case_passed = 0;
case_failed = 0;
case_failed_before = 0;
case_repeat_count = 0;
case_repeat_count = 1;
test_index_of_case++;
}
minar::Scheduler::postCallback(run_next_case);

View File

@ -85,19 +85,19 @@ namespace v1 {
const case_teardown_handler_t teardown_handler,
const case_failure_handler_t failure_handler = default_handler);
// overloads for case_repeat_count_handler_t
// overloads for case_call_count_handler_t
Case(const char *description,
const case_setup_handler_t setup_handler,
const case_repeat_count_handler_t case_handler,
const case_call_count_handler_t case_handler,
const case_teardown_handler_t teardown_handler = default_handler,
const case_failure_handler_t failure_handler = default_handler);
Case(const char *description,
const case_repeat_count_handler_t case_handler,
const case_call_count_handler_t case_handler,
const case_failure_handler_t failure_handler = default_handler);
Case(const char *description,
const case_repeat_count_handler_t case_handler,
const case_call_count_handler_t case_handler,
const case_teardown_handler_t teardown_handler,
const case_failure_handler_t failure_handler = default_handler);
@ -113,7 +113,7 @@ namespace v1 {
const case_handler_t handler;
const case_control_handler_t control_handler;
const case_repeat_count_handler_t repeat_count_handler;
const case_call_count_handler_t repeat_count_handler;
const case_setup_handler_t setup_handler;
const case_teardown_handler_t teardown_handler;

View File

@ -63,7 +63,7 @@ namespace v1 {
{
const case_handler_t handler = case_handler_t(NULL);
const case_control_handler_t control = case_control_handler_t(NULL);
const case_repeat_count_handler_t repeat_count = case_repeat_count_handler_t(NULL);
const case_call_count_handler_t call_count = case_call_count_handler_t(NULL);
const test_setup_handler_t test_setup = test_setup_handler_t(1);
const test_teardown_handler_t test_teardown = test_teardown_handler_t(1);
@ -75,7 +75,7 @@ namespace v1 {
operator case_handler_t() const { return handler; }
operator case_control_handler_t() const { return control; }
operator case_repeat_count_handler_t() const { return repeat_count; }
operator case_call_count_handler_t() const { return call_count; }
operator test_setup_handler_t() const { return test_setup; }
operator test_teardown_handler_t() const { return test_teardown; }

View File

@ -80,21 +80,22 @@ namespace v1 {
* Instead of using this class directly it is recommended to use the aliases for clearer
* semantics:
* @code
* control_t test_case(const size_t repeat_count) {
* control_t test_case(const size_t call_count) {
* // repeat 5 times for a total of 6 calls
* return (repeat_count < 5) ? CaseRepeatHandler : CaseNext;
* return (call_count < 6) ? CaseRepeatHandler : CaseNext;
* }
* @endcode
*
* This class overloads the `+` operator to implement something similiar to saturated arbitration:
* - The lower timeout value "wins".
* - A more involved repeat "wins" (ie. `ALL` > 'HANDLER' > 'NONE').
* - Next Case always wins.
*
* You may then add timeouts and repeats together:
* @code
* control_t test_case(const size_t repeat_count) {
* control_t test_case(const size_t call_count) {
* // repeat 5 times for a total of 6 calls, each with a 500ms asynchronous timeout
* return CaseTimeout(500) + ((repeat_count < 5) ? CaseRepeatAll : CaseNext);
* return CaseTimeout(500) + ((call_count < 6) ? CaseRepeatAll : CaseNoRepeat);
* }
* @endcode
*
@ -259,12 +260,12 @@ namespace v1 {
* This handler is called only if the case setup succeeded and then may be repeated or
* awaiting a asynchronous callback, depending on the return modifiers.
*
* @param repeat_count starting at `0`, contains the number of times this handler has been called
* @param call_count starting at `1`, contains the number of times this handler has been called
*
* @returns
* A combination of control modifiers.
*/
typedef control_t (*case_repeat_count_handler_t)(const size_t repeat_count);
typedef control_t (*case_call_count_handler_t)(const size_t call_count);
/** Test case teardown handler.
*