Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Jul 7, 2017
1 parent 795e247 commit 72da246
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tests/src/core/testqgsexpression.cpp
Expand Up @@ -1123,6 +1123,18 @@ class TestQgsExpression: public QObject
// not like
QTest::newRow( "'a' not like 'a%'" ) << QStringLiteral( "'a' not like 'a%'" ) << false << QVariant( 0 );
QTest::newRow( "'a' not like 'a%'" ) << QStringLiteral( "'a' not like 'a%'" ) << false << QVariant( 0 );

// with_variable
QTest::newRow( "with_variable('five', 5, @five * 2)" ) << QStringLiteral( "with_variable('five', 5, @five * 2)" ) << false << QVariant( 10 );
QTest::newRow( "with_variable('nothing', NULL, COALESCE(@nothing, 'something'))" ) << QStringLiteral( "with_variable('nothing', NULL, COALESCE(@nothing, 'something'))" ) << false << QVariant( "something" );

// array_first, array_last
QTest::newRow( "array_first(array('a', 'b', 'c'))" ) << QStringLiteral( "array_first(array('a', 'b', 'c'))" ) << false << QVariant( "a" );
QTest::newRow( "array_first(array())" ) << QStringLiteral( "array_first(array())" ) << false << QVariant();
QTest::newRow( "array_last(array('a', 'b', 'c'))" ) << QStringLiteral( "array_last(array('a', 'b', 'c'))" ) << false << QVariant( "c" );
QTest::newRow( "array_last(array())" ) << QStringLiteral( "array_last(array())" ) << false << QVariant();

//
}

void run_evaluation_test( QgsExpression &exp, bool evalError, QVariant &expected )
Expand Down Expand Up @@ -1314,6 +1326,9 @@ class TestQgsExpression: public QObject
QTest::newRow( "get_feature no match2" ) << "get_feature('test','col2','no match!')" << false << -1;
//no matching layer
QTest::newRow( "get_feature no match layer" ) << "get_feature('not a layer!','col1',10)" << false << -1;

// get_feature_by_id
QTest::newRow( "get_feature_by_id" ) << "get_feature_by_id('test', 1)" << true << 1;
}

void eval_get_feature()
Expand Down

0 comments on commit 72da246

Please sign in to comment.