From 72dcf886bfaf66d4e1f448609a1c4d56d473f45a Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Thu, 27 Feb 2020 22:44:49 +0100 Subject: [PATCH] [contextualprocess] Improve tests, fix off-by-one - there's no string representation for a QVariantMap, so it won't be converted; in *debug* output it looks like there's a string there. - off-by-one when diving into compound selectors, spotted by test, now fixed. --- src/modules/contextualprocess/ContextualProcessJob.cpp | 2 +- src/modules/contextualprocess/Tests.cpp | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/modules/contextualprocess/ContextualProcessJob.cpp b/src/modules/contextualprocess/ContextualProcessJob.cpp index b0d7a6743..1173a3071 100644 --- a/src/modules/contextualprocess/ContextualProcessJob.cpp +++ b/src/modules/contextualprocess/ContextualProcessJob.cpp @@ -77,7 +77,7 @@ fetch( QString& value, QStringList& selector, int index, const QVariant& v ) } const QVariantMap map = v.toMap(); const QString& key = selector.at( index ); - if ( index == selector.length() ) + if ( index == selector.length() - 1) { value = map.value( key ).toString(); return map.contains( key ); diff --git a/src/modules/contextualprocess/Tests.cpp b/src/modules/contextualprocess/Tests.cpp index 8f3322455..a0071328a 100644 --- a/src/modules/contextualprocess/Tests.cpp +++ b/src/modules/contextualprocess/Tests.cpp @@ -88,6 +88,8 @@ ContextualProcessTests::testProcessListSampleConfig() void ContextualProcessTests::testFetch() { + Logger::setupLogLevel( Logger::LOGVERBOSE ); + QVariantMap m; // Some keys without sub-map m.insert( QStringLiteral( "carrot" ), true ); @@ -150,7 +152,7 @@ void ContextualProcessTests::testFetch() ContextualProcessBinding b( QStringLiteral( "berries" ) ); QString s; QVERIFY( b.fetch( gs, s ) ); - QVERIFY( s.contains( QStringLiteral( "QVariant" ) ) ); + QVERIFY( s.isEmpty() ); // No string representation } { // Compound lookup