@@ -48,6 +48,10 @@ class TestQgsSqliteUtils : public QObject
48
48
void testPrintfUtf8 ();
49
49
void testQuotedString_data ();
50
50
void testQuotedString ();
51
+ void testQuotedIdentifier_data ();
52
+ void testQuotedIdentifier ();
53
+ void testQuotedValue_data ();
54
+ void testQuotedValue ();
51
55
};
52
56
53
57
@@ -110,6 +114,44 @@ void TestQgsSqliteUtils::testQuotedString()
110
114
QCOMPARE ( QgsSqliteUtils::quotedString ( input ), expected );
111
115
}
112
116
117
+ void TestQgsSqliteUtils::testQuotedIdentifier_data ()
118
+ {
119
+ QTest::addColumn<QString>( " input" );
120
+ QTest::addColumn<QString>( " expected" );
121
+
122
+ QTest::newRow ( " myColumn" ) << " myColumn" << " \" myColumn\" " ;
123
+ QTest::newRow ( " my column" ) << " my column" << " \" my column\" " ;
124
+ }
125
+
126
+ void TestQgsSqliteUtils::testQuotedIdentifier ()
127
+ {
128
+ QFETCH ( QString, input );
129
+ QFETCH ( QString, expected );
130
+
131
+ QCOMPARE ( QgsSqliteUtils::quotedIdentifier ( input ), expected );
132
+ }
133
+
134
+ void TestQgsSqliteUtils::testQuotedValue_data ()
135
+ {
136
+ QTest::addColumn<QVariant>( " input" );
137
+ QTest::addColumn<QString>( " expected" );
138
+
139
+ QTest::newRow ( " String" ) << QVariant ( " Test string" ) << " 'Test string'" ;
140
+ QTest::newRow ( " Integer" ) << QVariant ( 5 ) << " 5" ;
141
+ QTest::newRow ( " Double" ) << QVariant ( 3.2 ) << " 3.2" ;
142
+ QTest::newRow ( " Boolean" ) << QVariant ( true ) << " 1" ;
143
+ QTest::newRow ( " Escaped string" ) << QVariant ( " It's a test string" ) << " 'It''s a test string'" ;
144
+ QTest::newRow ( " NULL" ) << QVariant () << " NULL" ;
145
+ }
146
+
147
+ void TestQgsSqliteUtils::testQuotedValue ()
148
+ {
149
+ QFETCH ( QVariant, input );
150
+ QFETCH ( QString, expected );
151
+
152
+ QCOMPARE ( QgsSqliteUtils::quotedValue ( input ), expected );
153
+ }
154
+
113
155
114
156
QGSTEST_MAIN ( TestQgsSqliteUtils )
115
157
#include " testqgssqliteutils.moc"
0 commit comments