Skip to content

Commit 157c7dc

Browse files
committed
Add test that now() returns static results
1 parent 2a080f0 commit 157c7dc

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

tests/src/core/testqgsexpression.cpp

+16
Original file line numberDiff line numberDiff line change
@@ -3127,6 +3127,22 @@ class TestQgsExpression: public QObject
31273127
QCOMPARE( QgsExpression::formatPreviewString( QVariant( stringList ) ),
31283128
QString( "<i>&lt;array: 'One', 'Two', 'A very long string that is going to be trunca…&gt;</i>" ) );
31293129
}
3130+
3131+
void test_nowStatic()
3132+
{
3133+
QgsExpression e( QStringLiteral( "now()" ) );
3134+
QgsExpressionContext ctx;
3135+
e.prepare( &ctx );
3136+
QVariant v = e.evaluate();
3137+
qDebug() << v.toString();
3138+
qDebug() << v.toDateTime().toMSecsSinceEpoch();
3139+
QTest::qSleep( 1000 );
3140+
QVariant v2 = e.evaluate();
3141+
qDebug() << v2.toString();
3142+
qDebug() << v2.toDateTime().toMSecsSinceEpoch();
3143+
3144+
QCOMPARE( v.toDateTime().toMSecsSinceEpoch(), v2.toDateTime().toMSecsSinceEpoch() );
3145+
}
31303146
};
31313147

31323148
QGSTEST_MAIN( TestQgsExpression )

0 commit comments

Comments
 (0)