Skip to content
Permalink
Browse files

Added missing QStringLiteral in tests

  • Loading branch information
domi4484 committed Apr 20, 2021
1 parent e99b92a commit d320a184473e7589ab0b59a45e8a5ba4368e5a57
Showing with 16 additions and 16 deletions.
  1. +4 −4 tests/src/core/testqgssettingsentry.cpp
  2. +12 −12 tests/src/core/testqgssettingsregistry.cpp
@@ -96,12 +96,12 @@ void TestQgsSettingsEntry::settingsKey()

void TestQgsSettingsEntry::enumValue()
{
QString settingsKey( "qgis/testing/my_enum_value_for_units" );
QString settingsKey( QStringLiteral( "qgis/testing/my_enum_value_for_units" ) );

// Make sure the setting is not existing
QgsSettings().remove( settingsKey, QgsSettings::NoSection );

QgsSettingsEntryEnum settingsEntryEnum( settingsKey, QgsSettings::NoSection, QgsUnitTypes::LayoutMeters, "Layout unit" );
QgsSettingsEntryEnum settingsEntryEnum( settingsKey, QgsSettings::NoSection, QgsUnitTypes::LayoutMeters, QStringLiteral( "Layout unit" ) );

// Check default value
QCOMPARE( settingsEntryEnum.defaultValue(), QgsUnitTypes::LayoutMeters );
@@ -142,15 +142,15 @@ void TestQgsSettingsEntry::enumValue()

void TestQgsSettingsEntry::flagValue()
{
QString settingsKey( "qgis/testing/my_flag_value_for_units" );
QString settingsKey( QStringLiteral( "qgis/testing/my_flag_value_for_units" ) );
QgsMapLayerProxyModel::Filters pointAndLine = QgsMapLayerProxyModel::Filters( QgsMapLayerProxyModel::PointLayer | QgsMapLayerProxyModel::LineLayer );
QgsMapLayerProxyModel::Filters pointAndPolygon = QgsMapLayerProxyModel::Filters( QgsMapLayerProxyModel::PointLayer | QgsMapLayerProxyModel::PolygonLayer );
QgsMapLayerProxyModel::Filters hasGeometry = QgsMapLayerProxyModel::Filters( QgsMapLayerProxyModel::HasGeometry );

// Make sure the setting is not existing
QgsSettings().remove( settingsKey, QgsSettings::NoSection );

QgsSettingsEntryFlag settingsEntryFlag( settingsKey, QgsSettings::NoSection, pointAndLine, "Filters" );
QgsSettingsEntryFlag settingsEntryFlag( settingsKey, QgsSettings::NoSection, pointAndLine, QStringLiteral( "Filters" ) );

// Check default value
QCOMPARE( settingsEntryFlag.defaultValue(), pointAndLine );
@@ -49,12 +49,12 @@ class TestQgsSettingsRegistry : public QObject

void TestQgsSettingsRegistry::getSettingsEntries()
{
QString settingsEntryBoolKey( "/qgis/testing/settingsEntryBool" );
QString settingsEntryBoolKey( QStringLiteral( "/qgis/testing/settingsEntryBool" ) );
QgsSettingsEntryBool settingsEntryBool( settingsEntryBoolKey, QgsSettings::NoSection, false );
QString settingsEntryIntegerKey( "/qgis/testing/settingsEntryInteger" );
QString settingsEntryIntegerKey( QStringLiteral( "/qgis/testing/settingsEntryInteger" ) );
QgsSettingsEntryBool settingsEntryInteger( settingsEntryIntegerKey, QgsSettings::NoSection, 123 );

QString settingsEntryInexisting( "/qgis/testing/settingsEntryInexisting" );
QString settingsEntryInexisting( QStringLiteral( "/qgis/testing/settingsEntryInexisting" ) );

SettingsRegistryTest settingsRegistry;
settingsRegistry.addSettingsEntry( nullptr ); // should not crash
@@ -68,34 +68,34 @@ void TestQgsSettingsRegistry::getSettingsEntries()

void TestQgsSettingsRegistry::getSettingsEntriesWithDynamicKeys()
{
QString settingsEntryBoolKey( "/qgis/testing/%1_settingsEntryBool" );
QString settingsEntryBoolKey( QStringLiteral( "/qgis/testing/%1_settingsEntryBool" ) );
QgsSettingsEntryBool settingsEntryBool( settingsEntryBoolKey, QgsSettings::NoSection, false );
QString settingsEntryIntegerKey( "/qgis/testing/%1/settingsEntryInteger" );
QString settingsEntryIntegerKey( QStringLiteral( "/qgis/testing/%1/settingsEntryInteger" ) );
QgsSettingsEntryInteger settingsEntryInteger( settingsEntryIntegerKey, QgsSettings::NoSection, 123 );
QString settingsEntryDoubleKey( "/qgis/testing/%1/settingsEntryDouble_%2" );
QString settingsEntryDoubleKey( QStringLiteral( "/qgis/testing/%1/settingsEntryDouble_%2" ) );
QgsSettingsEntryDouble settingsEntryDouble( settingsEntryDoubleKey, QgsSettings::NoSection, 1.23 );

QString settingsEntryInexisting( "/qgis/testing/settingsEntryInexisting%1" );
QString settingsEntryInexisting( QStringLiteral( "/qgis/testing/settingsEntryInexisting%1" ) );

SettingsRegistryTest settingsRegistry;
settingsRegistry.addSettingsEntry( &settingsEntryBool );
settingsRegistry.addSettingsEntry( &settingsEntryInteger );
settingsRegistry.addSettingsEntry( &settingsEntryDouble );

QCOMPARE( settingsRegistry.getSettingsEntry( settingsEntryBoolKey ), &settingsEntryBool );
QCOMPARE( settingsRegistry.getSettingsEntry( settingsEntryBoolKey.replace( "%1", "1st" ) ), &settingsEntryBool );
QCOMPARE( settingsRegistry.getSettingsEntry( settingsEntryBoolKey.replace( QStringLiteral( "%1" ), QStringLiteral( "1st" ) ) ), &settingsEntryBool );
QCOMPARE( settingsRegistry.getSettingsEntry( settingsEntryIntegerKey ), &settingsEntryInteger );
QCOMPARE( settingsRegistry.getSettingsEntry( settingsEntryIntegerKey.replace( "%1", "Second" ) ), &settingsEntryInteger );
QCOMPARE( settingsRegistry.getSettingsEntry( settingsEntryIntegerKey.replace( QStringLiteral( "%1" ), QStringLiteral( "Second" ) ) ), &settingsEntryInteger );
QCOMPARE( settingsRegistry.getSettingsEntry( settingsEntryDoubleKey ), &settingsEntryDouble );
QCOMPARE( settingsRegistry.getSettingsEntry( settingsEntryDoubleKey.replace( "%1", "1st" ).replace( "%2", "2nd" ) ), &settingsEntryDouble );
QCOMPARE( settingsRegistry.getSettingsEntry( settingsEntryDoubleKey.replace( QStringLiteral( "%1" ), QStringLiteral( "1st" ) ).replace( QStringLiteral( "%2" ), QStringLiteral( "2nd" ) ) ), &settingsEntryDouble );
QCOMPARE( settingsRegistry.getSettingsEntry( settingsEntryInexisting ), nullptr );
}

void TestQgsSettingsRegistry::childRegistry()
{
QString settingsEntryBoolKey( "/qgis/testing/settingsEntryBool" );
QString settingsEntryBoolKey( QStringLiteral( "/qgis/testing/settingsEntryBool" ) );
QgsSettingsEntryBool settingsEntryBool( settingsEntryBoolKey, QgsSettings::NoSection, false );
QString settingsEntryIntegerKey( "/qgis/testing/settingsEntryInteger" );
QString settingsEntryIntegerKey( QStringLiteral( "/qgis/testing/settingsEntryInteger" ) );
QgsSettingsEntryInteger settingsEntryInteger( settingsEntryIntegerKey, QgsSettings::NoSection, 123 );

SettingsRegistryTest settingsRegistryChild;

0 comments on commit d320a18

Please sign in to comment.