Add option for short circuit evaluation of conditions

This commit is contained in:
WarmUpTill
2024-08-30 21:21:21 +02:00
committed by WarmUpTill
parent 0906c6bb3f
commit c7c48d03e9
9 changed files with 168 additions and 46 deletions

View File

@@ -171,3 +171,20 @@ TEST_CASE("Logic", "[conditon-logic]")
REQUIRE(advss::Logic::ApplyConditionLogic(logic, true, false, ""));
REQUIRE(advss::Logic::ApplyConditionLogic(logic, true, true, ""));
}
TEST_CASE("Short circuit", "[conditon-logic]")
{
bool functionWasRun = false;
const auto testFunction = [&functionWasRun]() {
functionWasRun = true;
return true;
};
advss::Logic::ApplyConditionLogic(advss::Logic::Type::AND, false,
testFunction, "");
REQUIRE_FALSE(functionWasRun);
advss::Logic::ApplyConditionLogic(advss::Logic::Type::OR, false,
testFunction, "");
REQUIRE(functionWasRun);
}