| 499 | } |
| 500 | |
| 501 | void ExpressionParserTest::testevaluateLessThan() { |
| 502 | const QString expr = QStringLiteral("x < y"); |
| 503 | const QStringList vars = {QStringLiteral("x"), QStringLiteral("y")}; |
| 504 | |
| 505 | QVector<QVector<double>*> xVectors; |
| 506 | |
| 507 | xVectors << new QVector<double>({0., 1., 0., 1., -1., -std::numeric_limits<double>::infinity(), 1, std::numeric_limits<double>::infinity(), 7.}); // x |
| 508 | xVectors << new QVector<double>({0., 0., 1., 1., -2., std::numeric_limits<double>::infinity(), std::nan("0"), 1e9, 7.}); // y |
| 509 | QVector<double> yVector({5., 5., 5., 5., 5., 5., 5., 5., 5.}); // random value |
| 510 | auto* parser = ExpressionParser::getInstance(); |
| 511 | parser->tryEvaluateCartesian(expr, vars, xVectors, &yVector); |
| 512 | |
| 513 | QCOMPARE(yVector.size(), 9); |
| 514 | QCOMPARE(yVector.at(0), 0.); |
| 515 | QCOMPARE(yVector.at(1), 0.); |
| 516 | QCOMPARE(yVector.at(2), 1.); |
| 517 | QCOMPARE(yVector.at(3), 0.); |
| 518 | QCOMPARE(yVector.at(4), 0.); |
| 519 | QCOMPARE(yVector.at(5), 1.); |
| 520 | QCOMPARE(yVector.at(6), 0.); |
| 521 | QCOMPARE(yVector.at(7), 0.); |
| 522 | QCOMPARE(yVector.at(8), 0.); |
| 523 | } |
| 524 | |
| 525 | void ExpressionParserTest::testevaluateLessEqualThan() { |
| 526 | const QString expr = QStringLiteral("x <= y"); |
nothing calls this directly
no test coverage detected