MCPcopy Create free account
hub / github.com/KDE/labplot / testEvaluateNot

Method testEvaluateNot

tests/backend/gsl/ExpressionParserTest.cpp:420–436  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

418}
419
420void ExpressionParserTest::testEvaluateNot() {
421 const QString expr = QStringLiteral("!x");
422 const QStringList vars = {QStringLiteral("x")};
423
424 QVector<QVector<double>*> xVectors;
425
426 xVectors << new QVector<double>({1., 0., -1., 2.}); // x
427 QVector<double> yVector({5., 5., 5., 5.}); // random value
428 auto* parser = ExpressionParser::getInstance();
429 parser->tryEvaluateCartesian(expr, vars, xVectors, &yVector);
430
431 QCOMPARE(yVector.size(), 4);
432 QCOMPARE(yVector.at(0), 0.);
433 QCOMPARE(yVector.at(1), 1.);
434 QCOMPARE(yVector.at(2), 0.); // According to C/C++ standard, -1 is true for bool and therefore the negated is false
435 QCOMPARE(yVector.at(3), 0.);
436}
437
438void ExpressionParserTest::testEvaluateLogicalExpression() {
439 const QString expr = QStringLiteral("!x || y && x");

Callers

nothing calls this directly

Calls 2

tryEvaluateCartesianMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected