constant number of assertions in unittests
This commit is contained in:
parent
70fd9ff3e5
commit
941bf61f28
@ -45,10 +45,17 @@ TEST_CASE("Command Executor", "[hal][linux]") {
|
|||||||
while (result != CommandExecutor::EXECUTION_FINISHED) {
|
while (result != CommandExecutor::EXECUTION_FINISHED) {
|
||||||
limitIdx++;
|
limitIdx++;
|
||||||
result = cmdExecutor.check(bytesHaveBeenRead);
|
result = cmdExecutor.check(bytesHaveBeenRead);
|
||||||
|
// to have constant assertion count, we first check condition
|
||||||
|
// and then force a failed assertion
|
||||||
|
if (result == CommandExecutor::COMMAND_ERROR) {
|
||||||
REQUIRE(result != CommandExecutor::COMMAND_ERROR);
|
REQUIRE(result != CommandExecutor::COMMAND_ERROR);
|
||||||
|
}
|
||||||
usleep(500);
|
usleep(500);
|
||||||
|
// same as above
|
||||||
|
if (limitIdx >= 500) {
|
||||||
REQUIRE(limitIdx < 500);
|
REQUIRE(limitIdx < 500);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
limitIdx = 0;
|
limitIdx = 0;
|
||||||
CHECK(bytesHaveBeenRead == true);
|
CHECK(bytesHaveBeenRead == true);
|
||||||
@ -75,11 +82,18 @@ TEST_CASE("Command Executor", "[hal][linux]") {
|
|||||||
while (result != CommandExecutor::EXECUTION_FINISHED) {
|
while (result != CommandExecutor::EXECUTION_FINISHED) {
|
||||||
limitIdx++;
|
limitIdx++;
|
||||||
result = cmdExecutor.check(bytesHaveBeenRead);
|
result = cmdExecutor.check(bytesHaveBeenRead);
|
||||||
|
// to have constant assertion count, we first check condition
|
||||||
|
// and then force a failed assertion
|
||||||
|
if (result == CommandExecutor::COMMAND_ERROR) {
|
||||||
REQUIRE(result != CommandExecutor::COMMAND_ERROR);
|
REQUIRE(result != CommandExecutor::COMMAND_ERROR);
|
||||||
|
}
|
||||||
// This ensures that the tests do not block indefinitely
|
// This ensures that the tests do not block indefinitely
|
||||||
usleep(500);
|
usleep(500);
|
||||||
|
// same as above
|
||||||
|
if (limitIdx >= 500) {
|
||||||
REQUIRE(limitIdx < 500);
|
REQUIRE(limitIdx < 500);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
limitIdx = 0;
|
limitIdx = 0;
|
||||||
CHECK(bytesHaveBeenRead == true);
|
CHECK(bytesHaveBeenRead == true);
|
||||||
CHECK(result == CommandExecutor::EXECUTION_FINISHED);
|
CHECK(result == CommandExecutor::EXECUTION_FINISHED);
|
||||||
@ -116,11 +130,18 @@ TEST_CASE("Command Executor", "[hal][linux]") {
|
|||||||
while (result != CommandExecutor::EXECUTION_FINISHED and result != returnvalue::FAILED) {
|
while (result != CommandExecutor::EXECUTION_FINISHED and result != returnvalue::FAILED) {
|
||||||
limitIdx++;
|
limitIdx++;
|
||||||
result = cmdExecutor.check(bytesHaveBeenRead);
|
result = cmdExecutor.check(bytesHaveBeenRead);
|
||||||
|
// to have constant assertion count, we first check condition
|
||||||
|
// and then force a failed assertion
|
||||||
|
if (result == CommandExecutor::COMMAND_ERROR) {
|
||||||
REQUIRE(result != CommandExecutor::COMMAND_ERROR);
|
REQUIRE(result != CommandExecutor::COMMAND_ERROR);
|
||||||
|
}
|
||||||
// This ensures that the tests do not block indefinitely
|
// This ensures that the tests do not block indefinitely
|
||||||
usleep(500);
|
usleep(500);
|
||||||
|
// same as above
|
||||||
|
if (limitIdx >= 500) {
|
||||||
REQUIRE(limitIdx < 500);
|
REQUIRE(limitIdx < 500);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
REQUIRE(result == returnvalue::FAILED);
|
REQUIRE(result == returnvalue::FAILED);
|
||||||
REQUIRE(cmdExecutor.getLastError() == 1);
|
REQUIRE(cmdExecutor.getLastError() == 1);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user