Skip to content
Permalink
Browse files

Fix build, warnings on windows

  • Loading branch information
nyalldawson committed Mar 1, 2017
1 parent fcf718f commit e9dee400677dbe9ae7aacfc8b6d3a8d9b28ed2e9
Showing with 22 additions and 8 deletions.
  1. +15 −1 tests/src/core/testqgsexpression.cpp
  2. +7 −7 tests/src/core/testqgsproperty.cpp
@@ -2674,21 +2674,35 @@ class TestQgsExpression: public QObject
{
QgsExpressionContext context;

#ifdef Q_OS_WIN
_putenv( "TESTENV_STRING=Hello World" );
#else
setenv( "TESTENV_STRING", "Hello World", 1 );
#endif

QgsExpression e( "env('TESTENV_STRING')" );

QVariant result = e.evaluate( &context );

QCOMPARE( result.toString(), QStringLiteral( "Hello World" ) );
#ifdef Q_OS_WIN
_putenv( "TESTENV_STRING=" );
_putenv( "TESTENV_INT=5" );
#else
unsetenv( "TESTENV_STRING" );

setenv( "TESTENV_INT", "5", 1 );
#endif

QgsExpression e2( "env('TESTENV_INT')" );

QVariant result2 = e2.evaluate( &context );

QCOMPARE( result2.toString(), QStringLiteral( "5" ) );
#ifdef Q_OS_WIN
_putenv( "TESTENV_INT=" );
#else
unsetenv( "TESTENV_INT" );
#endif

QgsExpression e3( "env('TESTENV_I_DO_NOT_EXIST')" );
QVariant result3 = e3.evaluate( &context );
@@ -48,7 +48,7 @@ class TestTransformer : public QgsPropertyTransformer
{
return new TestTransformer( mMinValue, mMaxValue );
}
virtual QString toExpression( const QString& ) const override { return QStringLiteral(); }
virtual QString toExpression( const QString& ) const override { return QString(); }

private:

@@ -104,10 +104,10 @@ void TestQgsProperty::initTestCase()
{
QgsApplication::init();
QgsApplication::initQgis();
mDefinitions.insert( Property1, QgsPropertyDefinition( "p1", QgsPropertyDefinition::DataTypeString, QStringLiteral(), QStringLiteral() ) );
mDefinitions.insert( Property2, QgsPropertyDefinition( "p2", QgsPropertyDefinition::DataTypeString, QStringLiteral(), QStringLiteral() ) );
mDefinitions.insert( Property3, QgsPropertyDefinition( "p3", QgsPropertyDefinition::DataTypeString, QStringLiteral(), QStringLiteral() ) );
mDefinitions.insert( Property4, QgsPropertyDefinition( "p4", QgsPropertyDefinition::DataTypeString, QStringLiteral(), QStringLiteral() ) );
mDefinitions.insert( Property1, QgsPropertyDefinition( "p1", QgsPropertyDefinition::DataTypeString, QString(), QString() ) );
mDefinitions.insert( Property2, QgsPropertyDefinition( "p2", QgsPropertyDefinition::DataTypeString, QString(), QString() ) );
mDefinitions.insert( Property3, QgsPropertyDefinition( "p3", QgsPropertyDefinition::DataTypeString, QString(), QString() ) );
mDefinitions.insert( Property4, QgsPropertyDefinition( "p4", QgsPropertyDefinition::DataTypeString, QString(), QString() ) );
}

void TestQgsProperty::cleanupTestCase()
@@ -388,7 +388,7 @@ void TestQgsProperty::fieldBasedProperty()
property.setField( "bad_field" );
QCOMPARE( property.value( context, -1 ).toInt(), -1 );
// unset field name
QgsProperty defaultProperty = QgsProperty::fromField( QStringLiteral() );
QgsProperty defaultProperty = QgsProperty::fromField( QString() );
QCOMPARE( defaultProperty.value( context, -1 ).toInt(), -1 );
QVERIFY( defaultProperty.referencedFields( context ).isEmpty() );
defaultProperty.setActive( true );
@@ -493,7 +493,7 @@ void TestQgsProperty::expressionBasedProperty()
QCOMPARE( property.value( context, -1 ).toInt(), -1 );
QVERIFY( property.referencedFields( context ).isEmpty() );
// unset expression
QgsProperty defaultProperty = QgsProperty::fromExpression( QStringLiteral() );
QgsProperty defaultProperty = QgsProperty::fromExpression( QString() );
QCOMPARE( defaultProperty.value( context, -1 ).toInt(), -1 );
QVERIFY( defaultProperty.referencedFields( context ).isEmpty() );
defaultProperty.setActive( true );

0 comments on commit e9dee40

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