@@ -1827,16 +1827,21 @@ void TestQgsProcessing::parameters()
1827
1827
// as bool
1828
1828
def->setName ( QStringLiteral ( " double" ) );
1829
1829
QCOMPARE ( QgsProcessingParameters::parameterAsBool ( def.get (), params, context ), true );
1830
+ QCOMPARE ( QgsProcessingParameters::parameterAsBoolean ( def.get (), params, context ), true );
1830
1831
def->setName ( QStringLiteral ( " int" ) );
1831
1832
QCOMPARE ( QgsProcessingParameters::parameterAsBool ( def.get (), params, context ), true );
1833
+ QCOMPARE ( QgsProcessingParameters::parameterAsBoolean ( def.get (), params, context ), true );
1832
1834
def->setName ( QStringLiteral ( " bool" ) );
1833
1835
QCOMPARE ( QgsProcessingParameters::parameterAsBool ( def.get (), params, context ), true );
1836
+ QCOMPARE ( QgsProcessingParameters::parameterAsBoolean ( def.get (), params, context ), true );
1834
1837
def->setName ( QStringLiteral ( " prop" ) );
1835
1838
QCOMPARE ( QgsProcessingParameters::parameterAsBool ( def.get (), params, context ), true );
1839
+ QCOMPARE ( QgsProcessingParameters::parameterAsBoolean ( def.get (), params, context ), true );
1836
1840
f.setAttribute ( 0 , false );
1837
1841
context.expressionContext ().setFeature ( f );
1838
1842
def->setName ( QStringLiteral ( " prop" ) );
1839
1843
QCOMPARE ( QgsProcessingParameters::parameterAsBool ( def.get (), params, context ), false );
1844
+ QCOMPARE ( QgsProcessingParameters::parameterAsBoolean ( def.get (), params, context ), false );
1840
1845
1841
1846
// as layer
1842
1847
def->setName ( QStringLiteral ( " double" ) );
@@ -1996,12 +2001,16 @@ void TestQgsProcessing::parameterBoolean()
1996
2001
QVariantMap params;
1997
2002
params.insert ( " no_def" , false );
1998
2003
QCOMPARE ( QgsProcessingParameters::parameterAsBool ( nullptr , params, context ), false );
2004
+ QCOMPARE ( QgsProcessingParameters::parameterAsBoolean ( nullptr , params, context ), false );
1999
2005
params.insert ( " no_def" , " false" );
2000
2006
QCOMPARE ( QgsProcessingParameters::parameterAsBool ( nullptr , params, context ), false );
2007
+ QCOMPARE ( QgsProcessingParameters::parameterAsBoolean ( nullptr , params, context ), false );
2001
2008
params.insert ( " no_def" , QVariant () );
2002
2009
QCOMPARE ( QgsProcessingParameters::parameterAsBool ( nullptr , params, context ), false );
2010
+ QCOMPARE ( QgsProcessingParameters::parameterAsBoolean ( nullptr , params, context ), false );
2003
2011
params.remove ( " no_def" );
2004
2012
QCOMPARE ( QgsProcessingParameters::parameterAsBool ( nullptr , params, context ), false );
2013
+ QCOMPARE ( QgsProcessingParameters::parameterAsBoolean ( nullptr , params, context ), false );
2005
2014
2006
2015
// with defs
2007
2016
@@ -2014,18 +2023,24 @@ void TestQgsProcessing::parameterBoolean()
2014
2023
2015
2024
params.insert ( " non_optional_default_false" , false );
2016
2025
QCOMPARE ( QgsProcessingParameters::parameterAsBool ( def.get (), params, context ), false );
2026
+ QCOMPARE ( QgsProcessingParameters::parameterAsBoolean ( def.get (), params, context ), false );
2017
2027
params.insert ( " non_optional_default_false" , true );
2018
2028
QCOMPARE ( QgsProcessingParameters::parameterAsBool ( def.get (), params, context ), true );
2029
+ QCOMPARE ( QgsProcessingParameters::parameterAsBoolean ( def.get (), params, context ), true );
2019
2030
params.insert ( " non_optional_default_false" , " true" );
2020
2031
QCOMPARE ( QgsProcessingParameters::parameterAsBool ( def.get (), params, context ), true );
2032
+ QCOMPARE ( QgsProcessingParameters::parameterAsBoolean ( def.get (), params, context ), true );
2021
2033
params.insert ( " non_optional_default_false" , " false" );
2022
2034
QCOMPARE ( QgsProcessingParameters::parameterAsBool ( def.get (), params, context ), false );
2035
+ QCOMPARE ( QgsProcessingParameters::parameterAsBoolean ( def.get (), params, context ), false );
2023
2036
2024
2037
// non-optional - behavior is undefined, but internally default to false
2025
2038
params.insert ( " non_optional_default_false" , QVariant () );
2026
2039
QCOMPARE ( QgsProcessingParameters::parameterAsBool ( def.get (), params, context ), false );
2040
+ QCOMPARE ( QgsProcessingParameters::parameterAsBoolean ( def.get (), params, context ), false );
2027
2041
params.remove ( " non_optional_default_false" );
2028
2042
QCOMPARE ( QgsProcessingParameters::parameterAsBool ( def.get (), params, context ), false );
2043
+ QCOMPARE ( QgsProcessingParameters::parameterAsBoolean ( def.get (), params, context ), false );
2029
2044
2030
2045
QCOMPARE ( def->valueAsPythonString ( false , context ), QStringLiteral ( " False" ) );
2031
2046
QCOMPARE ( def->valueAsPythonString ( true , context ), QStringLiteral ( " True" ) );
@@ -2067,17 +2082,23 @@ void TestQgsProcessing::parameterBoolean()
2067
2082
2068
2083
params.insert ( " optional_default_true" , false );
2069
2084
QCOMPARE ( QgsProcessingParameters::parameterAsBool ( def.get (), params, context ), false );
2085
+ QCOMPARE ( QgsProcessingParameters::parameterAsBoolean ( def.get (), params, context ), false );
2070
2086
params.insert ( " optional_default_true" , true );
2071
2087
QCOMPARE ( QgsProcessingParameters::parameterAsBool ( def.get (), params, context ), true );
2088
+ QCOMPARE ( QgsProcessingParameters::parameterAsBoolean ( def.get (), params, context ), true );
2072
2089
params.insert ( " optional_default_true" , " true" );
2073
2090
QCOMPARE ( QgsProcessingParameters::parameterAsBool ( def.get (), params, context ), true );
2091
+ QCOMPARE ( QgsProcessingParameters::parameterAsBoolean ( def.get (), params, context ), true );
2074
2092
params.insert ( " optional_default_true" , " false" );
2075
2093
QCOMPARE ( QgsProcessingParameters::parameterAsBool ( def.get (), params, context ), false );
2094
+ QCOMPARE ( QgsProcessingParameters::parameterAsBoolean ( def.get (), params, context ), false );
2076
2095
// optional - should be default
2077
2096
params.insert ( " optional_default_true" , QVariant () );
2078
2097
QCOMPARE ( QgsProcessingParameters::parameterAsBool ( def.get (), params, context ), true );
2098
+ QCOMPARE ( QgsProcessingParameters::parameterAsBoolean ( def.get (), params, context ), true );
2079
2099
params.remove ( " optional_default_true" );
2080
2100
QCOMPARE ( QgsProcessingParameters::parameterAsBool ( def.get (), params, context ), true );
2101
+ QCOMPARE ( QgsProcessingParameters::parameterAsBoolean ( def.get (), params, context ), true );
2081
2102
2082
2103
pythonCode = def->asPythonString ();
2083
2104
QCOMPARE ( pythonCode, QStringLiteral ( " QgsProcessingParameterBoolean('optional_default_true', '', optional=True, defaultValue=True)" ) );
@@ -2106,17 +2127,23 @@ void TestQgsProcessing::parameterBoolean()
2106
2127
2107
2128
params.insert ( " optional_default_false" , false );
2108
2129
QCOMPARE ( QgsProcessingParameters::parameterAsBool ( def.get (), params, context ), false );
2130
+ QCOMPARE ( QgsProcessingParameters::parameterAsBoolean ( def.get (), params, context ), false );
2109
2131
params.insert ( " optional_default_false" , true );
2110
2132
QCOMPARE ( QgsProcessingParameters::parameterAsBool ( def.get (), params, context ), true );
2133
+ QCOMPARE ( QgsProcessingParameters::parameterAsBoolean ( def.get (), params, context ), true );
2111
2134
params.insert ( " optional_default_false" , " true" );
2112
2135
QCOMPARE ( QgsProcessingParameters::parameterAsBool ( def.get (), params, context ), true );
2136
+ QCOMPARE ( QgsProcessingParameters::parameterAsBoolean ( def.get (), params, context ), true );
2113
2137
params.insert ( " optional_default_false" , " false" );
2114
2138
QCOMPARE ( QgsProcessingParameters::parameterAsBool ( def.get (), params, context ), false );
2139
+ QCOMPARE ( QgsProcessingParameters::parameterAsBoolean ( def.get (), params, context ), false );
2115
2140
// optional - should be default
2116
2141
params.insert ( " optional_default_false" , QVariant () );
2117
2142
QCOMPARE ( QgsProcessingParameters::parameterAsBool ( def.get (), params, context ), false );
2143
+ QCOMPARE ( QgsProcessingParameters::parameterAsBoolean ( def.get (), params, context ), false );
2118
2144
params.remove ( " optional_default_false" );
2119
2145
QCOMPARE ( QgsProcessingParameters::parameterAsBool ( def.get (), params, context ), false );
2146
+ QCOMPARE ( QgsProcessingParameters::parameterAsBoolean ( def.get (), params, context ), false );
2120
2147
2121
2148
pythonCode = def->asPythonString ();
2122
2149
QCOMPARE ( pythonCode, QStringLiteral ( " QgsProcessingParameterBoolean('optional_default_false', '', optional=True, defaultValue=False)" ) );
@@ -2139,17 +2166,23 @@ void TestQgsProcessing::parameterBoolean()
2139
2166
2140
2167
params.insert ( " non_optional_default_true" , false );
2141
2168
QCOMPARE ( QgsProcessingParameters::parameterAsBool ( def.get (), params, context ), false );
2169
+ QCOMPARE ( QgsProcessingParameters::parameterAsBoolean ( def.get (), params, context ), false );
2142
2170
params.insert ( " non_optional_default_true" , true );
2143
2171
QCOMPARE ( QgsProcessingParameters::parameterAsBool ( def.get (), params, context ), true );
2172
+ QCOMPARE ( QgsProcessingParameters::parameterAsBoolean ( def.get (), params, context ), true );
2144
2173
params.insert ( " non_optional_default_true" , " true" );
2145
2174
QCOMPARE ( QgsProcessingParameters::parameterAsBool ( def.get (), params, context ), true );
2175
+ QCOMPARE ( QgsProcessingParameters::parameterAsBoolean ( def.get (), params, context ), true );
2146
2176
params.insert ( " non_optional_default_true" , " false" );
2147
2177
QCOMPARE ( QgsProcessingParameters::parameterAsBool ( def.get (), params, context ), false );
2178
+ QCOMPARE ( QgsProcessingParameters::parameterAsBoolean ( def.get (), params, context ), false );
2148
2179
// non-optional - behavior is undefined, but internally fallback to default
2149
2180
params.insert ( " non_optional_default_true" , QVariant () );
2150
2181
QCOMPARE ( QgsProcessingParameters::parameterAsBool ( def.get (), params, context ), true );
2182
+ QCOMPARE ( QgsProcessingParameters::parameterAsBoolean ( def.get (), params, context ), true );
2151
2183
params.remove ( " non_optional_default_true" );
2152
2184
QCOMPARE ( QgsProcessingParameters::parameterAsBool ( def.get (), params, context ), true );
2185
+ QCOMPARE ( QgsProcessingParameters::parameterAsBoolean ( def.get (), params, context ), true );
2153
2186
2154
2187
pythonCode = def->asPythonString ();
2155
2188
QCOMPARE ( pythonCode, QStringLiteral ( " QgsProcessingParameterBoolean('non_optional_default_true', '', defaultValue=True)" ) );
0 commit comments