| 134 | } |
| 135 | |
| 136 | void ObjectQueryTest::testOrQuery() |
| 137 | { |
| 138 | auto object = testObject(); |
| 139 | |
| 140 | auto true_1 = ObjectQuery(QLatin1String("a"), ObjectQuery::OperatorIs, QLatin1String("1")); |
| 141 | auto true_2 = ObjectQuery(QLatin1String("a"), ObjectQuery::OperatorIs, QLatin1String("1")); |
| 142 | ObjectQuery single_query_or_both_true{std::move(true_1), ObjectQuery::OperatorOr, std::move(true_2)}; |
| 143 | QVERIFY(single_query_or_both_true(object) == true); |
| 144 | QVERIFY(single_query_or_both_true == single_query_or_both_true); |
| 145 | QVERIFY(single_query_or_both_true != ObjectQuery{}); |
| 146 | |
| 147 | true_1 = ObjectQuery(QLatin1String("a"), ObjectQuery::OperatorIs, QLatin1String("1")); |
| 148 | auto false_1 = ObjectQuery(QLatin1String("a"), ObjectQuery::OperatorIs, QLatin1String("2")); |
| 149 | ObjectQuery single_query_or_left_true_right_false{std::move(true_1), ObjectQuery::OperatorOr, std::move(false_1)}; |
| 150 | QVERIFY(single_query_or_left_true_right_false(object) == true); |
| 151 | QVERIFY(single_query_or_left_true_right_false != single_query_or_both_true); |
| 152 | QVERIFY(single_query_or_both_true != single_query_or_left_true_right_false); |
| 153 | |
| 154 | true_1 = ObjectQuery(QLatin1String("a"), ObjectQuery::OperatorIs, QLatin1String("1")); |
| 155 | false_1 = ObjectQuery(QLatin1String("a"), ObjectQuery::OperatorIs, QLatin1String("2")); |
| 156 | ObjectQuery single_query_or_right_true_left_false{std::move(false_1), ObjectQuery::OperatorOr, std::move(true_1)}; |
| 157 | QVERIFY(single_query_or_right_true_left_false(object) == true); |
| 158 | |
| 159 | false_1 = ObjectQuery(QLatin1String("a"), ObjectQuery::OperatorIs, QLatin1String("2")); |
| 160 | auto false_2 = ObjectQuery(QLatin1String("a"), ObjectQuery::OperatorIs, QLatin1String("2")); |
| 161 | ObjectQuery single_query_or_both_false{std::move(false_1), ObjectQuery::OperatorOr, std::move(false_2)}; |
| 162 | QVERIFY(single_query_or_both_false(object) == false); |
| 163 | |
| 164 | auto operands = single_query_or_both_false.logicalOperands(); |
| 165 | QVERIFY(operands); |
| 166 | QVERIFY(operands->first.get()); |
| 167 | QCOMPARE(operands->first->getOperator(), ObjectQuery::OperatorIs); |
| 168 | QVERIFY(operands->second.get()); |
| 169 | QCOMPARE(operands->second->getOperator(), ObjectQuery::OperatorIs); |
| 170 | } |
| 171 | |
| 172 | void ObjectQueryTest::testAndQuery() |
| 173 | { |
nothing calls this directly
no test coverage detected