Skip to content
Permalink
Browse files

Add tests for load_json and write_json

  • Loading branch information
m-kuhn authored and nirvn committed Jan 18, 2019
1 parent fc54879 commit 6e0930ad7989b423253f9403b1012f775e16b67b
Showing with 4 additions and 0 deletions.
  1. +4 −0 tests/src/core/testqgsexpression.cpp
@@ -2962,7 +2962,11 @@ class TestQgsExpression: public QObject
QCOMPARE( QgsExpression( "map_concat(map('1', 'one', '2', 'overridden by next map'), map('2', 'two', '3', 'three'))" ).evaluate( &context ), QVariant( concatExpected ) );

QCOMPARE( QgsExpression( "json_to_map('{\"1\":\"one\",\"2\":\"two\",\"3\":\"three\"}')" ).evaluate( &context ), QVariant( concatExpected ) );
QCOMPARE( QgsExpression( "load_json('{\"1\":\"one\",\"2\":\"two\",\"3\":\"three\"}')" ).evaluate( &context ), QVariant( concatExpected ) );
QCOMPARE( QgsExpression( "load_json('[1,2,3]')" ).evaluate( &context ), QVariant( QVariantList() << 1 << 2 << 3 ) );
QCOMPARE( QgsExpression( "map_to_json(map('1','one','2','two','3','three'))" ).evaluate( &context ), QVariant( "{\"1\":\"one\",\"2\":\"two\",\"3\":\"three\"}" ) );
QCOMPARE( QgsExpression( "write_json(map('1','one','2','two','3','three'))" ).evaluate( &context ), QVariant( "{\"1\":\"one\",\"2\":\"two\",\"3\":\"three\"}" ) );
QCOMPARE( QgsExpression( "write_json(array(1,2,3))" ).evaluate( &context ), QVariant( QStringLiteral( "[1,2,3]" ) ) );

QCOMPARE( QgsExpression( "hstore_to_map('1=>one,2=>two,3=>three')" ).evaluate( &context ), QVariant( concatExpected ) );
QCOMPARE( QgsExpression( "map_to_hstore(map('1','one','2','two','3','three'))" ).evaluate( &context ), QVariant( "\"1\"=>\"one\",\"2\"=>\"two\",\"3\"=>\"three\"" ) );

0 comments on commit 6e0930a

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