Skip to content
Permalink
Browse files

fix lpad/rpad (fixes #9158)

  • Loading branch information
jef-n committed Dec 3, 2013
1 parent 9d17f25 commit bc825b4b46af8d8810abc4b5552921e891bf7bcf
Showing with 4 additions and 4 deletions.
  1. +2 −2 src/core/qgsexpression.cpp
  2. +2 −2 tests/src/core/testqgsexpression.cpp
@@ -756,15 +756,15 @@ static QVariant fcnRPad( const QVariantList& values, const QgsFeature* , QgsExpr
QString string = getStringValue( values.at( 0 ), parent );
int length = getIntValue( values.at( 1 ), parent );
QString fill = getStringValue( values.at( 2 ), parent );
return string.rightJustified( length, fill.at( 0 ), true );
return string.leftJustified( length, fill.at( 0 ), true ); }
}

static QVariant fcnLPad( const QVariantList& values, const QgsFeature* , QgsExpression *parent )
{
QString string = getStringValue( values.at( 0 ), parent );
int length = getIntValue( values.at( 1 ), parent );
QString fill = getStringValue( values.at( 2 ), parent );
return string.leftJustified( length, fill.at( 0 ), true );
return string.rightJustified( length, fill.at( 0 ), true );
}

static QVariant fcnFormatString( const QVariantList& values, const QgsFeature* , QgsExpression *parent )
@@ -308,9 +308,9 @@ class TestQgsExpression: public QObject
QTest::newRow( "strpos outside" ) << "strpos('Hello World','blah')" << false << QVariant( -1 );
QTest::newRow( "left" ) << "left('Hello World',5)" << false << QVariant( "Hello" );
QTest::newRow( "right" ) << "right('Hello World', 5)" << false << QVariant( "World" );
QTest::newRow( "rpad" ) << "rpad('Hello', 10, 'x')" << false << QVariant( "xxxxxHello" );
QTest::newRow( "rpad" ) << "rpad('Hello', 10, 'x')" << false << QVariant( "Helloxxxxx" );
QTest::newRow( "rpad truncate" ) << "rpad('Hello', 4, 'x')" << false << QVariant( "Hell" );
QTest::newRow( "lpad" ) << "lpad('Hello', 10, 'x')" << false << QVariant( "Helloxxxxx" );
QTest::newRow( "lpad" ) << "lpad('Hello', 10, 'x')" << false << QVariant( "xxxxxHello" );
QTest::newRow( "lpad truncate" ) << "rpad('Hello', 4, 'x')" << false << QVariant( "Hell" );
QTest::newRow( "title" ) << "title(' HeLlO WORLD ')" << false << QVariant( " Hello World " );
QTest::newRow( "trim" ) << "trim(' Test String ')" << false << QVariant( "Test String" );

0 comments on commit bc825b4

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