mirror of
https://github.com/qgis/QGIS.git
synced 2025-03-28 00:04:04 -04:00
followup: fix tests
This commit is contained in:
parent
800198be29
commit
b67dd4642b
@ -375,8 +375,8 @@ static QVariant fcnRndF( const QVariantList &values, const QgsExpressionContext
|
||||
return QVariant();
|
||||
|
||||
std::random_device rd;
|
||||
std::mt19937_64 generator(rd());
|
||||
std::uniform_real_distribution<double> dist(min, max);
|
||||
std::mt19937_64 generator( rd() );
|
||||
std::uniform_real_distribution<double> dist( min, max );
|
||||
|
||||
if ( !QgsExpressionUtils::isNull( values.at( 2 ) ) )
|
||||
{
|
||||
@ -397,7 +397,7 @@ static QVariant fcnRndF( const QVariantList &values, const QgsExpressionContext
|
||||
}
|
||||
|
||||
// Return a random integer in the range [min, max] (inclusive)
|
||||
return QVariant( dist(generator) );
|
||||
return QVariant( dist( generator ) );
|
||||
}
|
||||
static QVariant fcnRnd( const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent, const QgsExpressionNodeFunction * )
|
||||
{
|
||||
@ -407,8 +407,8 @@ static QVariant fcnRnd( const QVariantList &values, const QgsExpressionContext *
|
||||
return QVariant();
|
||||
|
||||
std::random_device rd;
|
||||
std::mt19937_64 generator(rd());
|
||||
std::uniform_int_distribution<qlonglong> dist(min, max);
|
||||
std::mt19937_64 generator( rd() );
|
||||
std::uniform_int_distribution<qlonglong> dist( min, max );
|
||||
|
||||
if ( !QgsExpressionUtils::isNull( values.at( 2 ) ) )
|
||||
{
|
||||
@ -429,7 +429,7 @@ static QVariant fcnRnd( const QVariantList &values, const QgsExpressionContext *
|
||||
}
|
||||
|
||||
// Return a random integer in the range [min, max] (inclusive)
|
||||
return QVariant( dist(generator) );
|
||||
return QVariant( dist( generator ) );
|
||||
}
|
||||
|
||||
static QVariant fcnLinearScale( const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent, const QgsExpressionNodeFunction * )
|
||||
|
@ -2209,16 +2209,16 @@ class TestQgsExpression: public QObject
|
||||
// Supports multiple type of seeds
|
||||
QgsExpression exp4( QStringLiteral( "randf(1,100,123)" ) );
|
||||
QVariant v4 = exp4.evaluate();
|
||||
QCOMPARE( v4.type(), QVariant::Float );
|
||||
QCOMPARE( v4.type(), QVariant::Double );
|
||||
QgsExpression exp5( QStringLiteral( "randf(1,100,1.23)" ) );
|
||||
QVariant v5 = exp5.evaluate();
|
||||
QCOMPARE( v5.type(), QVariant::Float );
|
||||
QCOMPARE( v5.type(), QVariant::Double );
|
||||
QgsExpression exp6( QStringLiteral( "randf(1,100,'123')" ) );
|
||||
QVariant v6 = exp6.evaluate();
|
||||
QCOMPARE( v6.type(), QVariant::Float );
|
||||
QCOMPARE( v6.type(), QVariant::Double );
|
||||
QgsExpression exp7( QStringLiteral( "randf(1,100,'abc')" ) );
|
||||
QVariant v7 = exp7.evaluate();
|
||||
QCOMPARE( v7.type(), QVariant::Float );
|
||||
QCOMPARE( v7.type(), QVariant::Double );
|
||||
|
||||
// Two calls with the same seed return the same numer
|
||||
QgsExpression exp8( QStringLiteral( "randf(seed:=1)" ) );
|
||||
|
Loading…
x
Reference in New Issue
Block a user