Skip to content
Permalink
Browse files

Add test that now() returns static results

  • Loading branch information
m-kuhn committed Aug 25, 2018
1 parent 2a080f0 commit 157c7dcd8f124760405fed22877e5dd89e249125
Showing with 16 additions and 0 deletions.
  1. +16 −0 tests/src/core/testqgsexpression.cpp
@@ -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 )

0 comments on commit 157c7dc

Please sign in to comment.
You can’t perform that action at this time.