Skip to content

Commit

Permalink
Expression tests: change Q_ASSERT to QVERIFY
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Dec 27, 2017
1 parent aa3bfff commit a4141c7
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions tests/src/core/testqgsexpression.cpp
Expand Up @@ -359,7 +359,7 @@ class TestQgsExpression: public QObject
}

QgsExpressionContext context;
Q_ASSERT( exp.prepare( &context ) );
QVERIFY( exp.prepare( &context ) );

QVariant res = exp.evaluate();
if ( exp.hasEvalError() )
Expand Down Expand Up @@ -388,10 +388,10 @@ class TestQgsExpression: public QObject
QgsExpression expression( "represent_value(\"Pilots\", 'Pilots')" );
if ( expression.hasParserError() )
qDebug() << expression.parserErrorString();
Q_ASSERT( !expression.hasParserError() );
QVERIFY( !expression.hasParserError() );
if ( expression.hasEvalError() )
qDebug() << expression.evalErrorString();
Q_ASSERT( !expression.hasEvalError() );
QVERIFY( !expression.hasEvalError() );
expression.prepare( &context );

QgsFeature feature;
Expand All @@ -403,10 +403,10 @@ class TestQgsExpression: public QObject
QgsExpression expression2( "represent_value(\"Class\", 'Class')" );
if ( expression2.hasParserError() )
qDebug() << expression2.parserErrorString();
Q_ASSERT( !expression2.hasParserError() );
QVERIFY( !expression2.hasParserError() );
if ( expression2.hasEvalError() )
qDebug() << expression2.evalErrorString();
Q_ASSERT( !expression2.hasEvalError() );
QVERIFY( !expression2.hasEvalError() );
expression2.prepare( &context );
mPointsLayer->getFeatures( QgsFeatureRequest().setFilterExpression( "Class = 'Jet'" ) ).nextFeature( feature );
context.setFeature( feature );
Expand All @@ -416,10 +416,10 @@ class TestQgsExpression: public QObject
QgsExpression expression3( "represent_value(\"Pilots\")" );
if ( expression3.hasParserError() )
qDebug() << expression.parserErrorString();
Q_ASSERT( !expression3.hasParserError() );
QVERIFY( !expression3.hasParserError() );
if ( expression3.hasEvalError() )
qDebug() << expression3.evalErrorString();
Q_ASSERT( !expression3.hasEvalError() );
QVERIFY( !expression3.hasEvalError() );

mPointsLayer->getFeatures( QgsFeatureRequest().setFilterExpression( "Pilots = 1" ) ).nextFeature( feature );
context.setFeature( feature );
Expand All @@ -428,12 +428,13 @@ class TestQgsExpression: public QObject
expression3.prepare( &context );
QCOMPARE( expression.evaluate( &context ).toString(), QStringLiteral( "one" ) );


QgsExpression expression4( "represent_value('Class')" );
if ( expression4.hasParserError() )
qDebug() << expression4.parserErrorString();
Q_ASSERT( !expression4.hasParserError() );
Q_ASSERT( expression4.hasEvalError() );
QVERIFY( !expression4.hasParserError() );
if ( expression4.hasEvalError() )
qDebug() << expression4.evalErrorString();
QVERIFY( expression4.hasEvalError() );
}

void evaluation_data()
Expand Down Expand Up @@ -1224,7 +1225,7 @@ class TestQgsExpression: public QObject

QgsExpressionContext context;

Q_ASSERT( exp.prepare( &context ) );
QVERIFY( exp.prepare( &context ) );

QVariant::Type resultType = result.type();
QVariant::Type expectedType = expected.type();
Expand Down Expand Up @@ -1278,7 +1279,7 @@ class TestQgsExpression: public QObject
break;
}
default:
Q_ASSERT( false ); // should never happen
QVERIFY( false ); // should never happen
}
}

Expand Down Expand Up @@ -2417,7 +2418,7 @@ class TestQgsExpression: public QObject
QgsExpression exp1( QStringLiteral( "eval()" ) );
QVariant v1 = exp1.evaluate( &context );

Q_ASSERT( !v1.isValid() );
QVERIFY( !v1.isValid() );

QgsExpression exp2( QStringLiteral( "eval('4')" ) );
QVariant v2 = exp2.evaluate( &context );
Expand Down Expand Up @@ -2903,7 +2904,7 @@ class TestQgsExpression: public QObject
QgsExpression e3( QStringLiteral( "env('TESTENV_I_DO_NOT_EXIST')" ) );
QVariant result3 = e3.evaluate( &context );

Q_ASSERT( result3.isNull() );
QVERIFY( result3.isNull() );
}

void test_formatPreviewString()
Expand Down

0 comments on commit a4141c7

Please sign in to comment.