Skip to content

Commit

Permalink
Add test that now() returns static results
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Aug 25, 2018
1 parent 2a080f0 commit 157c7dc
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tests/src/core/testqgsexpression.cpp
Expand Up @@ -3127,6 +3127,22 @@ class TestQgsExpression: public QObject
QCOMPARE( QgsExpression::formatPreviewString( QVariant( stringList ) ),
QString( "<i>&lt;array: 'One', 'Two', 'A very long string that is going to be trunca…&gt;</i>" ) );
}

void test_nowStatic()
{
QgsExpression e( QStringLiteral( "now()" ) );
QgsExpressionContext ctx;
e.prepare( &ctx );
QVariant v = e.evaluate();
qDebug() << v.toString();
qDebug() << v.toDateTime().toMSecsSinceEpoch();
QTest::qSleep( 1000 );
QVariant v2 = e.evaluate();
qDebug() << v2.toString();
qDebug() << v2.toDateTime().toMSecsSinceEpoch();

QCOMPARE( v.toDateTime().toMSecsSinceEpoch(), v2.toDateTime().toMSecsSinceEpoch() );
}
};

QGSTEST_MAIN( TestQgsExpression )
Expand Down

0 comments on commit 157c7dc

Please sign in to comment.