Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8a343847 authored by Yangster's avatar Yangster Committed by Yang Lu
Browse files

Return unknown for combination condition eval when operation is NOT and

there is no child.

Test: added unit test and rerun the statsd tests.

BUG: b/112311529

Change-Id: I0c5829e3cb26474b7dbcc05f20c4311e9f801d97
parent 60e22451
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -76,9 +76,9 @@ ConditionState evaluateCombinationCondition(const std::vector<int>& children,
            break;
        }
        case LogicalOperation::NOT:
            newCondition = (conditionCache[children[0]] == ConditionState::kFalse)
                                   ? ConditionState::kTrue
                                   : ConditionState::kFalse;
            newCondition = children.empty() ? ConditionState::kUnknown :
                              ((conditionCache[children[0]] == ConditionState::kFalse) ?
                                  ConditionState::kTrue : ConditionState::kFalse);
            break;
        case LogicalOperation::NAND:
            newCondition = hasFalse ? ConditionState::kTrue : ConditionState::kFalse;
+6 −0
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@ TEST(ConditionTrackerTest, TestUnknownCondition) {
    EXPECT_EQ(evaluateCombinationCondition(children, operation, conditionResults),
              ConditionState::kUnknown);
}

TEST(ConditionTrackerTest, TestAndCondition) {
    // Set up the matcher
    LogicalOperation operation = LogicalOperation::AND;
@@ -103,6 +104,11 @@ TEST(ConditionTrackerTest, TestNotCondition) {
    conditionResults.clear();
    conditionResults.push_back(ConditionState::kFalse);
    EXPECT_TRUE(evaluateCombinationCondition(children, operation, conditionResults));

    children.clear();
    conditionResults.clear();
    EXPECT_EQ(evaluateCombinationCondition(children, operation, conditionResults),
              ConditionState::kUnknown);
}

TEST(ConditionTrackerTest, TestNandCondition) {