sl@0
|
1 |
// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
//
|
sl@0
|
15 |
|
sl@0
|
16 |
#include <e32test.h>
|
sl@0
|
17 |
#include <e32math.h>
|
sl@0
|
18 |
#include <bautils.h>
|
sl@0
|
19 |
#include <sqldb.h>
|
sl@0
|
20 |
|
sl@0
|
21 |
///////////////////////////////////////////////////////////////////////////////////////
|
sl@0
|
22 |
|
sl@0
|
23 |
RTest TheTest(_L("t_sqllang test"));
|
sl@0
|
24 |
_LIT(KTestDir, "c:\\test\\");
|
sl@0
|
25 |
|
sl@0
|
26 |
_LIT(KTestDbName, "c:\\test\\t_sqllang_1.db");
|
sl@0
|
27 |
_LIT(KTestDbName2, "c:\\test\\t_sqllang_2.db");
|
sl@0
|
28 |
|
sl@0
|
29 |
RSqlDatabase TheDb;
|
sl@0
|
30 |
|
sl@0
|
31 |
///////////////////////////////////////////////////////////////////////////////////////
|
sl@0
|
32 |
|
sl@0
|
33 |
void DeleteTestFiles()
|
sl@0
|
34 |
{
|
sl@0
|
35 |
RSqlDatabase::Delete(KTestDbName2);
|
sl@0
|
36 |
RSqlDatabase::Delete(KTestDbName);
|
sl@0
|
37 |
}
|
sl@0
|
38 |
|
sl@0
|
39 |
///////////////////////////////////////////////////////////////////////////////////////
|
sl@0
|
40 |
///////////////////////////////////////////////////////////////////////////////////////
|
sl@0
|
41 |
//Test macros and functions
|
sl@0
|
42 |
void Check(TInt aValue, TInt aLine)
|
sl@0
|
43 |
{
|
sl@0
|
44 |
if(!aValue)
|
sl@0
|
45 |
{
|
sl@0
|
46 |
DeleteTestFiles();
|
sl@0
|
47 |
TheTest(EFalse, aLine);
|
sl@0
|
48 |
}
|
sl@0
|
49 |
}
|
sl@0
|
50 |
void Check(TInt aValue, TInt aExpected, TInt aLine)
|
sl@0
|
51 |
{
|
sl@0
|
52 |
if(aValue != aExpected)
|
sl@0
|
53 |
{
|
sl@0
|
54 |
DeleteTestFiles();
|
sl@0
|
55 |
RDebug::Print(_L("*** Expected error: %d, got: %d\r\n"), aExpected, aValue);
|
sl@0
|
56 |
TheTest(EFalse, aLine);
|
sl@0
|
57 |
}
|
sl@0
|
58 |
}
|
sl@0
|
59 |
void Check2(TInt64 aValue, TInt64 aExpected, TInt aLine)
|
sl@0
|
60 |
{
|
sl@0
|
61 |
if(aValue != aExpected)
|
sl@0
|
62 |
{
|
sl@0
|
63 |
DeleteTestFiles();
|
sl@0
|
64 |
RDebug::Print(_L("*** Expected error: %ld, got: %ld\r\n"), aExpected, aValue);
|
sl@0
|
65 |
TheTest(EFalse, aLine);
|
sl@0
|
66 |
}
|
sl@0
|
67 |
}
|
sl@0
|
68 |
#define TEST(arg) ::Check((arg), __LINE__)
|
sl@0
|
69 |
#define TEST2(aValue, aExpected) ::Check(aValue, aExpected, __LINE__)
|
sl@0
|
70 |
#define TEST3(aValue, aExpected) ::Check2(aValue, aExpected, __LINE__)
|
sl@0
|
71 |
|
sl@0
|
72 |
///////////////////////////////////////////////////////////////////////////////////////
|
sl@0
|
73 |
|
sl@0
|
74 |
void CreateTestDir()
|
sl@0
|
75 |
{
|
sl@0
|
76 |
RFs fs;
|
sl@0
|
77 |
TInt err = fs.Connect();
|
sl@0
|
78 |
TEST2(err, KErrNone);
|
sl@0
|
79 |
|
sl@0
|
80 |
err = fs.MkDir(KTestDir);
|
sl@0
|
81 |
TEST(err == KErrNone || err == KErrAlreadyExists);
|
sl@0
|
82 |
|
sl@0
|
83 |
fs.Close();
|
sl@0
|
84 |
}
|
sl@0
|
85 |
|
sl@0
|
86 |
///////////////////////////////////////////////////////////////////////////////////////
|
sl@0
|
87 |
|
sl@0
|
88 |
void PrintLastMsgIfError(TInt aErr)
|
sl@0
|
89 |
{
|
sl@0
|
90 |
if(aErr < 0 && SqlRetCodeClass(aErr) == ESqlDbError)
|
sl@0
|
91 |
{
|
sl@0
|
92 |
const TPtrC& msg = TheDb.LastErrorMessage();
|
sl@0
|
93 |
RDebug::Print(_L("Last error msg: \"%S\"\r\n"), &msg);
|
sl@0
|
94 |
}
|
sl@0
|
95 |
}
|
sl@0
|
96 |
|
sl@0
|
97 |
/**
|
sl@0
|
98 |
@SYMTestCaseID SYSLIB-SQL-CT-1611
|
sl@0
|
99 |
@SYMTestCaseDesc Create a table with INTEGER, SMALLINT, REAl, DOUBLE PRECISION, FLOAT, DECIMAL,...
|
sl@0
|
100 |
columns. Insert some records, retrieve the column values, verify the column values,
|
sl@0
|
101 |
try some mathematical operations with the column values, executed in the SQL
|
sl@0
|
102 |
statement.
|
sl@0
|
103 |
@SYMTestPriority High
|
sl@0
|
104 |
@SYMTestActions Testing SQL engine behaviour with different numerical types.
|
sl@0
|
105 |
Testing mathematical operations with numeric columns.
|
sl@0
|
106 |
@SYMTestExpectedResults Test must not fail
|
sl@0
|
107 |
@SYMREQ REQ5792
|
sl@0
|
108 |
REQ5793
|
sl@0
|
109 |
*/
|
sl@0
|
110 |
void NumericDataTypesTest()
|
sl@0
|
111 |
{
|
sl@0
|
112 |
TEST2(TheDb.Create(KTestDbName), KErrNone);
|
sl@0
|
113 |
|
sl@0
|
114 |
//Create a table with all possible numeric field types
|
sl@0
|
115 |
_LIT8(KSql1, "CREATE TABLE Tbl(A INTEGER, B SMALLINT, C REAL, D DOUBLE PRECISION, E FLOAT, \
|
sl@0
|
116 |
F DECIMAL, G BIGINT, H TINYINT, I BIT, J NUMERIC, K MONEY, \
|
sl@0
|
117 |
L SMALLMONEY)");
|
sl@0
|
118 |
TInt err = TheDb.Exec(KSql1);
|
sl@0
|
119 |
PrintLastMsgIfError(err);
|
sl@0
|
120 |
TEST(err >= 0);
|
sl@0
|
121 |
//Insert one record in to the created table
|
sl@0
|
122 |
_LIT8(KSql2, "INSERT INTO Tbl(A,B,C,D,E,F,G,H,I,J,K,L) VALUES(2000000000, 30000, 123.45, 0.912E+55,\
|
sl@0
|
123 |
1.34E-14, 1234.5678, 32000000000, 100, 7, 23.123456, 2123678.56, 11.45)");
|
sl@0
|
124 |
err = TheDb.Exec(KSql2);
|
sl@0
|
125 |
PrintLastMsgIfError(err);
|
sl@0
|
126 |
TEST2(err, 1);
|
sl@0
|
127 |
//Get the inserted record data
|
sl@0
|
128 |
RSqlStatement stmt;
|
sl@0
|
129 |
err = stmt.Prepare(TheDb, _L("SELECT * FROM TBL"));
|
sl@0
|
130 |
PrintLastMsgIfError(err);
|
sl@0
|
131 |
TEST2(err, KErrNone);
|
sl@0
|
132 |
err = stmt.Next();
|
sl@0
|
133 |
PrintLastMsgIfError(err);
|
sl@0
|
134 |
TEST2(err, KSqlAtRow);
|
sl@0
|
135 |
//Check column values
|
sl@0
|
136 |
TEST(stmt.ColumnInt(stmt.ColumnIndex(_L("a"))) == 2000000000);
|
sl@0
|
137 |
TEST(stmt.ColumnInt(stmt.ColumnIndex(_L("b"))) == 30000);
|
sl@0
|
138 |
TEST(Abs(stmt.ColumnReal(stmt.ColumnIndex(_L("c"))) - 123.45) < 0.000001);
|
sl@0
|
139 |
//The next column value test is not working! The extracted column value is 0.9120000000000002E+55
|
sl@0
|
140 |
//I guess the reason is that SQLITE uses manifest typing and "DOUBLE PRECISION" is not in its keyword
|
sl@0
|
141 |
//list. Maybe it is interpreted and stored as 4-byte float value.
|
sl@0
|
142 |
//TEST(Abs(stmt.ColumnReal(stmt.ColumnIndex(_L("d"))) - 0.912E+55) < 0.000001);
|
sl@0
|
143 |
TEST(Abs(stmt.ColumnReal(stmt.ColumnIndex(_L("e"))) - 1.34E-14) < 0.000001);
|
sl@0
|
144 |
TEST(stmt.ColumnReal(stmt.ColumnIndex(_L("f"))) == 1234.5678);
|
sl@0
|
145 |
TEST(stmt.ColumnInt64(stmt.ColumnIndex(_L("g"))) == 32000000000LL);
|
sl@0
|
146 |
TEST(stmt.ColumnInt(stmt.ColumnIndex(_L("h"))) == 100);
|
sl@0
|
147 |
TEST(stmt.ColumnInt(stmt.ColumnIndex(_L("i"))) == 7);
|
sl@0
|
148 |
TEST(Abs(stmt.ColumnReal(stmt.ColumnIndex(_L("j"))) - 23.123456) < 0.000001);
|
sl@0
|
149 |
TEST(Abs(stmt.ColumnReal(stmt.ColumnIndex(_L("k"))) - 2123678.56) < 0.000001);
|
sl@0
|
150 |
TEST(Abs(stmt.ColumnReal(stmt.ColumnIndex(_L("l"))) - 11.45) < 0.000001);
|
sl@0
|
151 |
stmt.Close();
|
sl@0
|
152 |
//The statement object has to be closed before TheDb.Exec() call,
|
sl@0
|
153 |
//otherwise the reported error is "database table is locked"
|
sl@0
|
154 |
//Insert second record in to the created table but inverse the column types!
|
sl@0
|
155 |
_LIT8(KSql3, "INSERT INTO Tbl(A, B, C, D, E, F, G, H, I, J,K,L) VALUES(\
|
sl@0
|
156 |
-2.5,1.1,12,23,45,111,5.6,7.9,1.1,2,6,7)");
|
sl@0
|
157 |
err = TheDb.Exec(KSql3);
|
sl@0
|
158 |
PrintLastMsgIfError(err);
|
sl@0
|
159 |
TEST2(err, 1);
|
sl@0
|
160 |
//Get the inserted record data
|
sl@0
|
161 |
err = stmt.Prepare(TheDb, _L("SELECT * FROM TBL"));
|
sl@0
|
162 |
PrintLastMsgIfError(err);
|
sl@0
|
163 |
TEST2(err, KErrNone);
|
sl@0
|
164 |
TEST2(stmt.Next(), KSqlAtRow);
|
sl@0
|
165 |
err = stmt.Next();
|
sl@0
|
166 |
PrintLastMsgIfError(err);
|
sl@0
|
167 |
TEST2(err, KSqlAtRow);
|
sl@0
|
168 |
//No column value checking because SQLITE inverted the column types!
|
sl@0
|
169 |
//Check column values
|
sl@0
|
170 |
TEST(Abs(stmt.ColumnReal(stmt.ColumnIndex(_L("a"))) - (-2.5)) < 0.000001);
|
sl@0
|
171 |
TEST(Abs(stmt.ColumnReal(stmt.ColumnIndex(_L("b"))) - 1.1) < 0.000001);
|
sl@0
|
172 |
TEST(stmt.ColumnInt(stmt.ColumnIndex(_L("c"))) == 12);
|
sl@0
|
173 |
TEST(stmt.ColumnInt(stmt.ColumnIndex(_L("d"))) == 23);
|
sl@0
|
174 |
TEST(stmt.ColumnInt(stmt.ColumnIndex(_L("e"))) == 45);
|
sl@0
|
175 |
TEST(stmt.ColumnInt(stmt.ColumnIndex(_L("f"))) == 111);
|
sl@0
|
176 |
TEST(Abs(stmt.ColumnReal(stmt.ColumnIndex(_L("g"))) - 5.6) < 0.000001);
|
sl@0
|
177 |
TEST(Abs(stmt.ColumnReal(stmt.ColumnIndex(_L("h"))) - 7.9) < 0.000001);
|
sl@0
|
178 |
TEST(Abs(stmt.ColumnReal(stmt.ColumnIndex(_L("i"))) - 1.1) < 0.000001);
|
sl@0
|
179 |
TEST(stmt.ColumnInt(stmt.ColumnIndex(_L("j"))) == 2);
|
sl@0
|
180 |
TEST(stmt.ColumnInt(stmt.ColumnIndex(_L("k"))) == 6);
|
sl@0
|
181 |
TEST(stmt.ColumnInt(stmt.ColumnIndex(_L("l"))) == 7);
|
sl@0
|
182 |
|
sl@0
|
183 |
stmt.Close();
|
sl@0
|
184 |
//Insert third record in to the created table
|
sl@0
|
185 |
_LIT8(KSql4, "INSERT INTO Tbl(A,B,C, D, E, F, G, H, I,J, K, L) VALUES(\
|
sl@0
|
186 |
2,3,123.45,1.5,2.5,1.56,320,100,7,23.123,212.56,11.45)");
|
sl@0
|
187 |
err = TheDb.Exec(KSql4);
|
sl@0
|
188 |
PrintLastMsgIfError(err);
|
sl@0
|
189 |
TEST2(err, 1);
|
sl@0
|
190 |
//Issue a "SELECT" statement doing there some arithmetic operations and comparisons on the column values.
|
sl@0
|
191 |
err = stmt.Prepare(TheDb, _L("SELECT A, A-C AS A2, K + L AS A3, H*I AS A4, E/D AS A5 FROM TBL WHERE A > 0 AND A < 10"));
|
sl@0
|
192 |
PrintLastMsgIfError(err);
|
sl@0
|
193 |
TEST2(err, KErrNone);
|
sl@0
|
194 |
TEST2(stmt.Next(), KSqlAtRow);
|
sl@0
|
195 |
//Check column values
|
sl@0
|
196 |
TEST2(stmt.ColumnInt(stmt.ColumnIndex(_L("a"))), 2);
|
sl@0
|
197 |
TEST(Abs(stmt.ColumnReal(stmt.ColumnIndex(_L("a2"))) - (2-123.45)) < 0.000001);
|
sl@0
|
198 |
TEST(Abs(stmt.ColumnReal(stmt.ColumnIndex(_L("a3"))) - (212.56+11.45)) < 0.000001);
|
sl@0
|
199 |
TEST(stmt.ColumnInt(stmt.ColumnIndex(_L("a4"))) == 700);
|
sl@0
|
200 |
TEST(Abs(stmt.ColumnReal(stmt.ColumnIndex(_L("a5"))) - (2.5/1.5)) < 0.000001);
|
sl@0
|
201 |
//There should be no more records
|
sl@0
|
202 |
TEST2(stmt.Next(), KSqlAtEnd);
|
sl@0
|
203 |
stmt.Close();
|
sl@0
|
204 |
|
sl@0
|
205 |
TheDb.Close();
|
sl@0
|
206 |
(void)RSqlDatabase::Delete(KTestDbName);
|
sl@0
|
207 |
}
|
sl@0
|
208 |
|
sl@0
|
209 |
/**
|
sl@0
|
210 |
@SYMTestCaseID SYSLIB-SQL-CT-1630
|
sl@0
|
211 |
@SYMTestCaseDesc Built-in functions test.
|
sl@0
|
212 |
abs(), coalesce(), ifnull(), last_insert_rowid(), length(), like(), lower(),
|
sl@0
|
213 |
max(), min(), nullif(), quote(), random(), round(), sqlite_version(), substr(),
|
sl@0
|
214 |
typeof(), upper(), avg(), count(), sun().
|
sl@0
|
215 |
@SYMTestPriority High
|
sl@0
|
216 |
@SYMTestActions Built-in functions test.
|
sl@0
|
217 |
@SYMTestExpectedResults Test must not fail
|
sl@0
|
218 |
@SYMREQ REQ5792
|
sl@0
|
219 |
REQ5793
|
sl@0
|
220 |
*/
|
sl@0
|
221 |
void BuiltInFunctionsTest()
|
sl@0
|
222 |
{
|
sl@0
|
223 |
(void)RSqlDatabase::Delete(KTestDbName);
|
sl@0
|
224 |
TInt err = TheDb.Create(KTestDbName);
|
sl@0
|
225 |
TEST2(err, KErrNone);
|
sl@0
|
226 |
|
sl@0
|
227 |
_LIT(KCreateSql, "CREATE TABLE A(Id Integer, \
|
sl@0
|
228 |
F1 Integer DEFAULT 0, \
|
sl@0
|
229 |
F2 Integer Default NULL, \
|
sl@0
|
230 |
F3 TEXT Default Null, \
|
sl@0
|
231 |
F4 TEXT Default Null)");
|
sl@0
|
232 |
err = TheDb.Exec(KCreateSql);
|
sl@0
|
233 |
TEST(err >= 0);
|
sl@0
|
234 |
|
sl@0
|
235 |
_LIT(KInsertSql1, "INSERT INTO A(Id, F1) VALUES(1, 100)");
|
sl@0
|
236 |
err = TheDb.Exec(KInsertSql1);
|
sl@0
|
237 |
TEST2(err, 1);
|
sl@0
|
238 |
|
sl@0
|
239 |
_LIT(KInsertSql2, "INSERT INTO A(Id, F1) VALUES(2, 1)");
|
sl@0
|
240 |
err = TheDb.Exec(KInsertSql2);
|
sl@0
|
241 |
TEST2(err, 1);
|
sl@0
|
242 |
|
sl@0
|
243 |
_LIT(KInsertSql3, "INSERT INTO A(Id, F3) VALUES(3, 'ABCD')");
|
sl@0
|
244 |
err = TheDb.Exec(KInsertSql3);
|
sl@0
|
245 |
TEST2(err, 1);
|
sl@0
|
246 |
|
sl@0
|
247 |
_LIT(KInsertSql4, "INSERT INTO A(Id, F4) VALUES(4, 'DCBA')");
|
sl@0
|
248 |
err = TheDb.Exec(KInsertSql4);
|
sl@0
|
249 |
TEST2(err, 1);
|
sl@0
|
250 |
|
sl@0
|
251 |
RSqlStatement stmt;
|
sl@0
|
252 |
|
sl@0
|
253 |
//abs() test --------------------------------------------------------
|
sl@0
|
254 |
err = stmt.Prepare(TheDb, _L("SELECT * FROM A WHERE F1 > ABS(-10)"));
|
sl@0
|
255 |
TEST2(err, KErrNone);
|
sl@0
|
256 |
err = stmt.Next();
|
sl@0
|
257 |
TEST2(err, KSqlAtRow);
|
sl@0
|
258 |
TEST(stmt.ColumnInt(1) == 100);
|
sl@0
|
259 |
stmt.Close();
|
sl@0
|
260 |
|
sl@0
|
261 |
//coalesce() test --------------------------------------------------------
|
sl@0
|
262 |
err = stmt.Prepare(TheDb, _L("SELECT COALESCE(F3, F4) AS F FROM A"));
|
sl@0
|
263 |
TEST2(err, KErrNone);
|
sl@0
|
264 |
|
sl@0
|
265 |
err = stmt.Next();
|
sl@0
|
266 |
TEST2(err, KSqlAtRow);
|
sl@0
|
267 |
TEST(stmt.IsNull(0));
|
sl@0
|
268 |
|
sl@0
|
269 |
err = stmt.Next();
|
sl@0
|
270 |
TEST2(err, KSqlAtRow);
|
sl@0
|
271 |
TEST(stmt.IsNull(0));
|
sl@0
|
272 |
|
sl@0
|
273 |
_LIT(KTextVal1, "ABCD");
|
sl@0
|
274 |
err = stmt.Next();
|
sl@0
|
275 |
TEST2(err, KSqlAtRow);
|
sl@0
|
276 |
TPtrC colVal;
|
sl@0
|
277 |
err = stmt.ColumnText(0, colVal);
|
sl@0
|
278 |
TEST2(err, KErrNone);
|
sl@0
|
279 |
TEST(colVal == KTextVal1);
|
sl@0
|
280 |
|
sl@0
|
281 |
_LIT(KTextVal2, "DCBA");
|
sl@0
|
282 |
err = stmt.Next();
|
sl@0
|
283 |
TEST2(err, KSqlAtRow);
|
sl@0
|
284 |
err = stmt.ColumnText(0, colVal);
|
sl@0
|
285 |
TEST2(err, KErrNone);
|
sl@0
|
286 |
TEST(colVal == KTextVal2);
|
sl@0
|
287 |
|
sl@0
|
288 |
stmt.Close();
|
sl@0
|
289 |
|
sl@0
|
290 |
//ifnull() test --------------------------------------------------------
|
sl@0
|
291 |
err = stmt.Prepare(TheDb, _L("SELECT IFNULL(F3, F4) AS F FROM A"));
|
sl@0
|
292 |
TEST2(err, KErrNone);
|
sl@0
|
293 |
|
sl@0
|
294 |
err = stmt.Next();
|
sl@0
|
295 |
TEST2(err, KSqlAtRow);
|
sl@0
|
296 |
TEST(stmt.IsNull(0));
|
sl@0
|
297 |
|
sl@0
|
298 |
err = stmt.Next();
|
sl@0
|
299 |
TEST2(err, KSqlAtRow);
|
sl@0
|
300 |
TEST(stmt.IsNull(0));
|
sl@0
|
301 |
|
sl@0
|
302 |
err = stmt.Next();
|
sl@0
|
303 |
TEST2(err, KSqlAtRow);
|
sl@0
|
304 |
err = stmt.ColumnText(0, colVal);
|
sl@0
|
305 |
TEST2(err, KErrNone);
|
sl@0
|
306 |
TEST(colVal == KTextVal1);
|
sl@0
|
307 |
|
sl@0
|
308 |
err = stmt.Next();
|
sl@0
|
309 |
TEST2(err, KSqlAtRow);
|
sl@0
|
310 |
err = stmt.ColumnText(0, colVal);
|
sl@0
|
311 |
TEST2(err, KErrNone);
|
sl@0
|
312 |
TEST(colVal == KTextVal2);
|
sl@0
|
313 |
|
sl@0
|
314 |
stmt.Close();
|
sl@0
|
315 |
|
sl@0
|
316 |
//last_insert_rowid() test --------------------------------------------------------
|
sl@0
|
317 |
err = stmt.Prepare(TheDb, _L("SELECT last_insert_rowid() AS F"));
|
sl@0
|
318 |
TEST2(err, KErrNone);
|
sl@0
|
319 |
err = stmt.Next();
|
sl@0
|
320 |
TEST2(err, KSqlAtRow);
|
sl@0
|
321 |
TInt64 colVal64 = stmt.ColumnInt64(0);
|
sl@0
|
322 |
RDebug::Print(_L("Last insert row id=%d\r\n"), (TInt)colVal64);
|
sl@0
|
323 |
stmt.Close();
|
sl@0
|
324 |
|
sl@0
|
325 |
//length() test --------------------------------------------------------
|
sl@0
|
326 |
err = stmt.Prepare(TheDb, _L("SELECT length(F4) AS L FROM A WHERE ID >= 3"));
|
sl@0
|
327 |
TEST2(err, KErrNone);
|
sl@0
|
328 |
|
sl@0
|
329 |
err = stmt.Next();
|
sl@0
|
330 |
TEST2(err, KSqlAtRow);
|
sl@0
|
331 |
TEST(stmt.ColumnInt(0) == 0);
|
sl@0
|
332 |
|
sl@0
|
333 |
err = stmt.Next();
|
sl@0
|
334 |
TEST2(err, KSqlAtRow);
|
sl@0
|
335 |
TEST(stmt.ColumnInt(0) == 4);
|
sl@0
|
336 |
|
sl@0
|
337 |
stmt.Close();
|
sl@0
|
338 |
|
sl@0
|
339 |
//like() test --------------------------------------------------------
|
sl@0
|
340 |
err = stmt.Prepare(TheDb, _L("SELECT Id FROM A WHERE F4 LIKE 'DC%'"));
|
sl@0
|
341 |
TEST2(err, KErrNone);
|
sl@0
|
342 |
err = stmt.Next();
|
sl@0
|
343 |
TEST2(err, KSqlAtRow);
|
sl@0
|
344 |
TEST(stmt.ColumnInt(0) == 4);
|
sl@0
|
345 |
stmt.Close();
|
sl@0
|
346 |
|
sl@0
|
347 |
_LIT(KInsertSql5, "INSERT INTO A(Id, F4) VALUES(5, 'ab%cd')");
|
sl@0
|
348 |
err = TheDb.Exec(KInsertSql5);
|
sl@0
|
349 |
TEST2(err, 1);
|
sl@0
|
350 |
|
sl@0
|
351 |
err = stmt.Prepare(TheDb, _L("SELECT Id FROM A WHERE F4 LIKE 'ab/%cd' ESCAPE '/'"));
|
sl@0
|
352 |
TEST2(err, KErrNone);
|
sl@0
|
353 |
err = stmt.Next();
|
sl@0
|
354 |
TEST2(err, KSqlAtRow);
|
sl@0
|
355 |
TEST(stmt.ColumnInt(0) == 5);
|
sl@0
|
356 |
stmt.Close();
|
sl@0
|
357 |
|
sl@0
|
358 |
err = stmt.Prepare(TheDb, _L8("SELECT Id FROM A WHERE F4 LIKE 'ab/%cd' ESCAPE '/'"));
|
sl@0
|
359 |
TEST2(err, KErrNone);
|
sl@0
|
360 |
err = stmt.Next();
|
sl@0
|
361 |
TEST2(err, KSqlAtRow);
|
sl@0
|
362 |
TEST(stmt.ColumnInt(0) == 5);
|
sl@0
|
363 |
stmt.Close();
|
sl@0
|
364 |
|
sl@0
|
365 |
//lower() test --------------------------------------------------------
|
sl@0
|
366 |
err = stmt.Prepare(TheDb, _L("SELECT LOWER(F3) FROM A WHERE F3 = 'ABCD'"));
|
sl@0
|
367 |
TEST2(err, KErrNone);
|
sl@0
|
368 |
err = stmt.Next();
|
sl@0
|
369 |
TEST2(err, KSqlAtRow);
|
sl@0
|
370 |
err = stmt.ColumnText(0, colVal);
|
sl@0
|
371 |
TEST2(err, KErrNone);
|
sl@0
|
372 |
_LIT(KTextVal3, "abcd");
|
sl@0
|
373 |
TEST(colVal == KTextVal3);
|
sl@0
|
374 |
stmt.Close();
|
sl@0
|
375 |
|
sl@0
|
376 |
//max() test --------------------------------------------------------
|
sl@0
|
377 |
err = stmt.Prepare(TheDb, _L("SELECT MAX(F1) AS M FROM A"));
|
sl@0
|
378 |
TEST2(err, KErrNone);
|
sl@0
|
379 |
err = stmt.Next();
|
sl@0
|
380 |
TEST2(err, KSqlAtRow);
|
sl@0
|
381 |
TEST(stmt.ColumnInt(0) == 100);
|
sl@0
|
382 |
stmt.Close();
|
sl@0
|
383 |
|
sl@0
|
384 |
//min() test --------------------------------------------------------
|
sl@0
|
385 |
err = stmt.Prepare(TheDb, _L("SELECT MIN(F1) AS M FROM A"));
|
sl@0
|
386 |
TEST2(err, KErrNone);
|
sl@0
|
387 |
err = stmt.Next();
|
sl@0
|
388 |
TEST2(err, KSqlAtRow);
|
sl@0
|
389 |
TEST(stmt.ColumnInt(0) == 0);
|
sl@0
|
390 |
stmt.Close();
|
sl@0
|
391 |
|
sl@0
|
392 |
//nullif() test --------------------------------------------------------
|
sl@0
|
393 |
err = stmt.Prepare(TheDb, _L("SELECT NULLIF(3, 4) AS M"));
|
sl@0
|
394 |
TEST2(err, KErrNone);
|
sl@0
|
395 |
err = stmt.Next();
|
sl@0
|
396 |
TEST2(err, KSqlAtRow);
|
sl@0
|
397 |
TEST(stmt.ColumnInt(0) == 3);
|
sl@0
|
398 |
stmt.Close();
|
sl@0
|
399 |
|
sl@0
|
400 |
err = stmt.Prepare(TheDb, _L("SELECT NULLIF(4, 4) AS M"));
|
sl@0
|
401 |
TEST2(err, KErrNone);
|
sl@0
|
402 |
err = stmt.Next();
|
sl@0
|
403 |
TEST2(err, KSqlAtRow);
|
sl@0
|
404 |
TEST(stmt.IsNull(0));
|
sl@0
|
405 |
stmt.Close();
|
sl@0
|
406 |
|
sl@0
|
407 |
//quote() test --------------------------------------------------------
|
sl@0
|
408 |
err = stmt.Prepare(TheDb, _L("SELECT QUOTE(F4) AS M FROM A WHERE Id = 5"));
|
sl@0
|
409 |
TEST2(err, KErrNone);
|
sl@0
|
410 |
err = stmt.Next();
|
sl@0
|
411 |
TEST2(err, KSqlAtRow);
|
sl@0
|
412 |
err = stmt.ColumnText(0, colVal);
|
sl@0
|
413 |
TEST2(err, KErrNone);
|
sl@0
|
414 |
_LIT(KTextVal4, "'ab%cd'");
|
sl@0
|
415 |
TEST(colVal == KTextVal4);
|
sl@0
|
416 |
stmt.Close();
|
sl@0
|
417 |
|
sl@0
|
418 |
//random() test --------------------------------------------------------
|
sl@0
|
419 |
err = stmt.Prepare(TheDb, _L("SELECT * FROM A WHERE Id > RANDOM(*)"));
|
sl@0
|
420 |
TEST2(err, KErrNone);
|
sl@0
|
421 |
stmt.Close();
|
sl@0
|
422 |
|
sl@0
|
423 |
//round() test --------------------------------------------------------
|
sl@0
|
424 |
err = stmt.Prepare(TheDb, _L("SELECT ROUND(5.4) AS D"));
|
sl@0
|
425 |
TEST2(err, KErrNone);
|
sl@0
|
426 |
err = stmt.Next();
|
sl@0
|
427 |
TEST2(err, KSqlAtRow);
|
sl@0
|
428 |
TEST(Abs(stmt.ColumnReal(0) - 5.0) < 0.000001);
|
sl@0
|
429 |
stmt.Close();
|
sl@0
|
430 |
|
sl@0
|
431 |
err = stmt.Prepare(TheDb, _L("SELECT ROUND(5.4321, 2) AS D"));
|
sl@0
|
432 |
TEST2(err, KErrNone);
|
sl@0
|
433 |
err = stmt.Next();
|
sl@0
|
434 |
TEST2(err, KSqlAtRow);
|
sl@0
|
435 |
TEST(Abs(stmt.ColumnReal(0) - 5.43) < 0.000001);
|
sl@0
|
436 |
stmt.Close();
|
sl@0
|
437 |
|
sl@0
|
438 |
//sqlite_version() test --------------------------------------------------------
|
sl@0
|
439 |
err = stmt.Prepare(TheDb, _L("SELECT sqlite_version(*) AS V"));
|
sl@0
|
440 |
TEST2(err, KErrNone);
|
sl@0
|
441 |
err = stmt.Next();
|
sl@0
|
442 |
TEST2(err, KSqlAtRow);
|
sl@0
|
443 |
err = stmt.ColumnText(0, colVal);
|
sl@0
|
444 |
TEST2(err, KErrNone);
|
sl@0
|
445 |
RDebug::Print(_L("Database engine version: \"%S\"\r\n"), &colVal);
|
sl@0
|
446 |
stmt.Close();
|
sl@0
|
447 |
|
sl@0
|
448 |
//substr() test --------------------------------------------------------
|
sl@0
|
449 |
err = stmt.Prepare(TheDb, _L("SELECT SUBSTR('abcd', 2, 2) AS S"));
|
sl@0
|
450 |
TEST2(err, KErrNone);
|
sl@0
|
451 |
err = stmt.Next();
|
sl@0
|
452 |
TEST2(err, KSqlAtRow);
|
sl@0
|
453 |
err = stmt.ColumnText(0, colVal);
|
sl@0
|
454 |
TEST2(err, KErrNone);
|
sl@0
|
455 |
_LIT(KTextVal7, "bc");
|
sl@0
|
456 |
TEST(colVal == KTextVal7);
|
sl@0
|
457 |
stmt.Close();
|
sl@0
|
458 |
|
sl@0
|
459 |
err = stmt.Prepare(TheDb, _L("SELECT SUBSTR('abcd', -3, 2) AS S"));
|
sl@0
|
460 |
TEST2(err, KErrNone);
|
sl@0
|
461 |
err = stmt.Next();
|
sl@0
|
462 |
TEST2(err, KSqlAtRow);
|
sl@0
|
463 |
err = stmt.ColumnText(0, colVal);
|
sl@0
|
464 |
TEST2(err, KErrNone);
|
sl@0
|
465 |
TEST(colVal == KTextVal7);
|
sl@0
|
466 |
stmt.Close();
|
sl@0
|
467 |
|
sl@0
|
468 |
//typeof() test --------------------------------------------------------
|
sl@0
|
469 |
_LIT(KInsertSql6, "INSERT INTO A(Id, F2) VALUES(6, 2)");
|
sl@0
|
470 |
err = TheDb.Exec(KInsertSql6);
|
sl@0
|
471 |
TEST2(err, 1);
|
sl@0
|
472 |
|
sl@0
|
473 |
err = stmt.Prepare(TheDb, _L("SELECT TYPEOF(F1 + F2) AS T FROM A WHERE ID > 4"));
|
sl@0
|
474 |
TEST2(err, KErrNone);
|
sl@0
|
475 |
|
sl@0
|
476 |
err = stmt.Next();
|
sl@0
|
477 |
TEST2(err, KSqlAtRow);
|
sl@0
|
478 |
err = stmt.ColumnText(0, colVal);
|
sl@0
|
479 |
TEST2(err, KErrNone);
|
sl@0
|
480 |
_LIT(KTextVal8, "null");
|
sl@0
|
481 |
TEST(colVal == KTextVal8);
|
sl@0
|
482 |
|
sl@0
|
483 |
err = stmt.Next();
|
sl@0
|
484 |
TEST2(err, KSqlAtRow);
|
sl@0
|
485 |
err = stmt.ColumnText(0, colVal);
|
sl@0
|
486 |
TEST2(err, KErrNone);
|
sl@0
|
487 |
_LIT(KTextVal9, "integer");
|
sl@0
|
488 |
TEST(colVal == KTextVal9);
|
sl@0
|
489 |
|
sl@0
|
490 |
stmt.Close();
|
sl@0
|
491 |
|
sl@0
|
492 |
//upper() test --------------------------------------------------------
|
sl@0
|
493 |
err = stmt.Prepare(TheDb, _L("SELECT UPPER('ghjk') AS U"));
|
sl@0
|
494 |
TEST2(err, KErrNone);
|
sl@0
|
495 |
err = stmt.Next();
|
sl@0
|
496 |
TEST2(err, KSqlAtRow);
|
sl@0
|
497 |
err = stmt.ColumnText(0, colVal);
|
sl@0
|
498 |
TEST2(err, KErrNone);
|
sl@0
|
499 |
_LIT(KTextVal10, "GHJK");
|
sl@0
|
500 |
TEST(colVal == KTextVal10);
|
sl@0
|
501 |
stmt.Close();
|
sl@0
|
502 |
|
sl@0
|
503 |
//avg() test --------------------------------------------------------
|
sl@0
|
504 |
err = stmt.Prepare(TheDb, _L("SELECT AVG(F2) AS F FROM A"));
|
sl@0
|
505 |
TEST2(err, KErrNone);
|
sl@0
|
506 |
err = stmt.Next();
|
sl@0
|
507 |
TEST2(err, KSqlAtRow);
|
sl@0
|
508 |
TEST(Abs(stmt.ColumnReal(0) - 2) < 0.000001);
|
sl@0
|
509 |
stmt.Close();
|
sl@0
|
510 |
|
sl@0
|
511 |
//count() test --------------------------------------------------------
|
sl@0
|
512 |
err = stmt.Prepare(TheDb, _L("SELECT COUNT(F2) AS F FROM A"));
|
sl@0
|
513 |
TEST2(err, KErrNone);
|
sl@0
|
514 |
err = stmt.Next();
|
sl@0
|
515 |
TEST2(err, KSqlAtRow);
|
sl@0
|
516 |
TEST(stmt.ColumnInt(0) == 1);
|
sl@0
|
517 |
stmt.Close();
|
sl@0
|
518 |
|
sl@0
|
519 |
err = stmt.Prepare(TheDb, _L("SELECT COUNT(*) AS F FROM A"));
|
sl@0
|
520 |
TEST2(err, KErrNone);
|
sl@0
|
521 |
err = stmt.Next();
|
sl@0
|
522 |
TEST2(err, KSqlAtRow);
|
sl@0
|
523 |
TEST(stmt.ColumnInt(0) == 6);
|
sl@0
|
524 |
stmt.Close();
|
sl@0
|
525 |
|
sl@0
|
526 |
//sum() test --------------------------------------------------------
|
sl@0
|
527 |
err = stmt.Prepare(TheDb, _L("SELECT SUM(F2) AS S FROM A"));
|
sl@0
|
528 |
TEST2(err, KErrNone);
|
sl@0
|
529 |
err = stmt.Next();
|
sl@0
|
530 |
TEST2(err, KSqlAtRow);
|
sl@0
|
531 |
TEST(Abs(stmt.ColumnReal(0) - 2) < 0.000001);
|
sl@0
|
532 |
stmt.Close();
|
sl@0
|
533 |
|
sl@0
|
534 |
// ----------------------------------
|
sl@0
|
535 |
TheDb.Close();
|
sl@0
|
536 |
(void)RSqlDatabase::Delete(KTestDbName);
|
sl@0
|
537 |
}
|
sl@0
|
538 |
|
sl@0
|
539 |
/**
|
sl@0
|
540 |
@SYMTestCaseID SYSLIB-SQL-CT-1632
|
sl@0
|
541 |
@SYMTestCaseDesc "ATTACH DATABASE" test.
|
sl@0
|
542 |
The test creates two databases. The main database has
|
sl@0
|
543 |
Account(Id Integer, PersonId Integer, Value Integer) table.
|
sl@0
|
544 |
The attached database has Person(Id Integer, Name TEXT) table.
|
sl@0
|
545 |
The test inserts some records with a valid relation between them in both tables.
|
sl@0
|
546 |
Then the test opens tha main database and attaches the second database to the first one.
|
sl@0
|
547 |
The test prepares and executes SQL statement which retrieves column values from both
|
sl@0
|
548 |
Account and Person tables. The test checks the column values.
|
sl@0
|
549 |
@SYMTestPriority High
|
sl@0
|
550 |
@SYMTestActions "ATTACH DATABASE" test.
|
sl@0
|
551 |
@SYMTestExpectedResults Test must not fail
|
sl@0
|
552 |
@SYMREQ REQ5792
|
sl@0
|
553 |
REQ5793
|
sl@0
|
554 |
*/
|
sl@0
|
555 |
void AttachDatabaseTest()
|
sl@0
|
556 |
{
|
sl@0
|
557 |
// ------------------------------------------------------------
|
sl@0
|
558 |
RSqlDatabase db2;
|
sl@0
|
559 |
TInt err = db2.Create(KTestDbName2);
|
sl@0
|
560 |
TEST2(err, KErrNone);
|
sl@0
|
561 |
|
sl@0
|
562 |
err = db2.Exec(_L("CREATE TABLE Person(Id Integer, Name TEXT)"));
|
sl@0
|
563 |
TEST(err >= 0);
|
sl@0
|
564 |
|
sl@0
|
565 |
err = db2.Exec(_L("INSERT INTO Person(Id, Name) VALUES(1, 'A')"));
|
sl@0
|
566 |
TEST2(err, 1);
|
sl@0
|
567 |
|
sl@0
|
568 |
err = db2.Exec(_L("INSERT INTO Person(Id, Name) VALUES(2, 'B')"));
|
sl@0
|
569 |
TEST2(err, 1);
|
sl@0
|
570 |
|
sl@0
|
571 |
err = db2.Exec(_L("INSERT INTO Person(Id, Name) VALUES(3, 'C')"));
|
sl@0
|
572 |
TEST2(err, 1);
|
sl@0
|
573 |
|
sl@0
|
574 |
db2.Close();
|
sl@0
|
575 |
|
sl@0
|
576 |
// ------------------------------------------------------------
|
sl@0
|
577 |
(void)RSqlDatabase::Delete(KTestDbName);
|
sl@0
|
578 |
err = TheDb.Create(KTestDbName);
|
sl@0
|
579 |
TEST2(err, KErrNone);
|
sl@0
|
580 |
|
sl@0
|
581 |
err = TheDb.Exec(_L("CREATE TABLE Account(Id Integer, PersonId Integer, Value Integer)"));
|
sl@0
|
582 |
TEST(err >= 0);
|
sl@0
|
583 |
|
sl@0
|
584 |
err = TheDb.Exec(_L("INSERT INTO ACCOUNT(Id, PersonId, Value) VALUES(1, 2, 20)"));
|
sl@0
|
585 |
TEST2(err, 1);
|
sl@0
|
586 |
|
sl@0
|
587 |
err = TheDb.Exec(_L("INSERT INTO ACCOUNT(Id, PersonId, Value) VALUES(2, 1, 10)"));
|
sl@0
|
588 |
TEST2(err, 1);
|
sl@0
|
589 |
|
sl@0
|
590 |
err = TheDb.Exec(_L("INSERT INTO ACCOUNT(Id, PersonId, Value) VALUES(3, 2, 25)"));
|
sl@0
|
591 |
TEST2(err, 1);
|
sl@0
|
592 |
|
sl@0
|
593 |
err = TheDb.Exec(_L("INSERT INTO ACCOUNT(Id, PersonId, Value) VALUES(4, 3, 30)"));
|
sl@0
|
594 |
TEST2(err, 1);
|
sl@0
|
595 |
|
sl@0
|
596 |
TheDb.Close();
|
sl@0
|
597 |
|
sl@0
|
598 |
// ------------------------------------------------------------
|
sl@0
|
599 |
err = TheDb.Open(KTestDbName);
|
sl@0
|
600 |
TEST2(err, KErrNone);
|
sl@0
|
601 |
|
sl@0
|
602 |
TBuf<100> sql;
|
sl@0
|
603 |
sql.Copy(_L("ATTACH DATABASE '"));
|
sl@0
|
604 |
sql.Append(KTestDbName2);
|
sl@0
|
605 |
sql.Append(_L("' AS DB2"));
|
sl@0
|
606 |
err = TheDb.Exec(sql);
|
sl@0
|
607 |
TEST(err >= 0);
|
sl@0
|
608 |
|
sl@0
|
609 |
RSqlStatement stmt;
|
sl@0
|
610 |
err = stmt.Prepare(TheDb, _L("SELECT Account.Value, DB2.Person.Name FROM Account, DB2.Person \
|
sl@0
|
611 |
WHERE Account.PersonId = DB2.Person.Id"));
|
sl@0
|
612 |
TEST2(err, KErrNone);
|
sl@0
|
613 |
|
sl@0
|
614 |
TPtrC personName;
|
sl@0
|
615 |
_LIT(KName1, "A");
|
sl@0
|
616 |
_LIT(KName2, "B");
|
sl@0
|
617 |
_LIT(KName3, "C");
|
sl@0
|
618 |
|
sl@0
|
619 |
err = stmt.Next();
|
sl@0
|
620 |
TEST2(err, KSqlAtRow);
|
sl@0
|
621 |
err = stmt.ColumnText(1, personName);
|
sl@0
|
622 |
TEST2(err, KErrNone);
|
sl@0
|
623 |
TEST(personName == KName2);
|
sl@0
|
624 |
TEST(stmt.ColumnInt(0) == 20);
|
sl@0
|
625 |
|
sl@0
|
626 |
err = stmt.Next();
|
sl@0
|
627 |
TEST2(err, KSqlAtRow);
|
sl@0
|
628 |
err = stmt.ColumnText(1, personName);
|
sl@0
|
629 |
TEST2(err, KErrNone);
|
sl@0
|
630 |
TEST(personName == KName1);
|
sl@0
|
631 |
TEST(stmt.ColumnInt(0) == 10);
|
sl@0
|
632 |
|
sl@0
|
633 |
err = stmt.Next();
|
sl@0
|
634 |
TEST2(err, KSqlAtRow);
|
sl@0
|
635 |
err = stmt.ColumnText(1, personName);
|
sl@0
|
636 |
TEST2(err, KErrNone);
|
sl@0
|
637 |
TEST(personName == KName2);
|
sl@0
|
638 |
TEST(stmt.ColumnInt(0) == 25);
|
sl@0
|
639 |
|
sl@0
|
640 |
err = stmt.Next();
|
sl@0
|
641 |
TEST2(err, KSqlAtRow);
|
sl@0
|
642 |
err = stmt.ColumnText(1, personName);
|
sl@0
|
643 |
TEST2(err, KErrNone);
|
sl@0
|
644 |
TEST(personName == KName3);
|
sl@0
|
645 |
TEST(stmt.ColumnInt(0) == 30);
|
sl@0
|
646 |
|
sl@0
|
647 |
stmt.Close();
|
sl@0
|
648 |
|
sl@0
|
649 |
err = TheDb.Exec(_L("DETACH DATABASE DB2"));
|
sl@0
|
650 |
TEST(err >= 0);
|
sl@0
|
651 |
|
sl@0
|
652 |
// ------------------------------------------------------------
|
sl@0
|
653 |
TheDb.Close();
|
sl@0
|
654 |
(void)RSqlDatabase::Delete(KTestDbName2);
|
sl@0
|
655 |
(void)RSqlDatabase::Delete(KTestDbName);
|
sl@0
|
656 |
}
|
sl@0
|
657 |
|
sl@0
|
658 |
/**
|
sl@0
|
659 |
@SYMTestCaseID SYSLIB-SQL-UT-3502
|
sl@0
|
660 |
@SYMTestCaseDesc Test for DEF109100: SQL, code coverage for TSqlBufRIterator is very low.
|
sl@0
|
661 |
The test creates a test table with INT32, INT64, DOUBLE, TEXT, and BINARY columns
|
sl@0
|
662 |
and inserts couple of records there. Then the test prepares a SELECT statement,
|
sl@0
|
663 |
retrieves all table rows, and to retrieve each column value, calls RSqlStatement::ColumnInt().
|
sl@0
|
664 |
The column values are carefully chosen, so some of the ColumnInt() calls have to round
|
sl@0
|
665 |
or clamp the returned value.
|
sl@0
|
666 |
Summary: the test checks the ColumnInt() behaviour when the column value type is not INT32 and
|
sl@0
|
667 |
when the column value is too big or too small and cannot fit in 32 bits.
|
sl@0
|
668 |
@SYMTestPriority High
|
sl@0
|
669 |
@SYMTestActions Test for DEF109100: SQL, code coverage for TSqlBufRIterator is very low.
|
sl@0
|
670 |
@SYMTestExpectedResults Test must not fail
|
sl@0
|
671 |
@SYMDEF DEF109100
|
sl@0
|
672 |
*/
|
sl@0
|
673 |
void ColumnIntTest()
|
sl@0
|
674 |
{
|
sl@0
|
675 |
(void)RSqlDatabase::Delete(KTestDbName);
|
sl@0
|
676 |
TInt err = TheDb.Create(KTestDbName);
|
sl@0
|
677 |
TEST2(err, KErrNone);
|
sl@0
|
678 |
err = TheDb.Exec(_L("CREATE TABLE A(I32 INTEGER,I64 INTEGER,D DOUBLE,T TEXT,B BINARY)"));
|
sl@0
|
679 |
TEST(err >= 0);
|
sl@0
|
680 |
|
sl@0
|
681 |
err = TheDb.Exec(_L("INSERT INTO A VALUES(-5,-5000000000,-10000000000.0,'AAA',x'1122FF')"));
|
sl@0
|
682 |
TEST2(err, 1);
|
sl@0
|
683 |
err = TheDb.Exec(_L("INSERT INTO A VALUES(5,5000000000,10000000000.0,NULL,NULL)"));
|
sl@0
|
684 |
TEST2(err, 1);
|
sl@0
|
685 |
err = TheDb.Exec(_L("INSERT INTO A VALUES(5,2000000000,1000000000.0,NULL,NULL)"));
|
sl@0
|
686 |
TEST2(err, 1);
|
sl@0
|
687 |
err = TheDb.Exec(_L("INSERT INTO A VALUES(NULL,NULL,1.1234567890123456E+317,NULL,NULL)"));
|
sl@0
|
688 |
TEST2(err, 1);
|
sl@0
|
689 |
|
sl@0
|
690 |
RSqlStatement stmt;
|
sl@0
|
691 |
err = stmt.Prepare(TheDb, _L("SELECT I32,I64,D,T,B FROM A"));
|
sl@0
|
692 |
TEST2(err, KErrNone);
|
sl@0
|
693 |
|
sl@0
|
694 |
err = stmt.Next();
|
sl@0
|
695 |
TEST2(err, KSqlAtRow);
|
sl@0
|
696 |
TInt val = stmt.ColumnInt(0);
|
sl@0
|
697 |
TEST2(val, -5); //"-5" is a 32-bit integer value
|
sl@0
|
698 |
val = stmt.ColumnInt(1);
|
sl@0
|
699 |
TEST2(val, KMinTInt); //"-5000000000" is a 64-bit integer, will be clamped to KMinTInt
|
sl@0
|
700 |
val = stmt.ColumnInt(2);
|
sl@0
|
701 |
TEST2(val, KMinTInt); //"-10000000000.0" is a 64-bit double, will be rounded to the nearest 32-bit integer
|
sl@0
|
702 |
val = stmt.ColumnInt(3);
|
sl@0
|
703 |
TEST2(val, 0); //"AAA" is a text string, cannot be converted to a 32-bit integer
|
sl@0
|
704 |
val = stmt.ColumnInt(4);
|
sl@0
|
705 |
TEST2(val, 0); //"1122FF" is a hex binary, cannot be converted to a 32-bit integer
|
sl@0
|
706 |
|
sl@0
|
707 |
err = stmt.Next();
|
sl@0
|
708 |
TEST2(err, KSqlAtRow);
|
sl@0
|
709 |
val = stmt.ColumnInt(0);
|
sl@0
|
710 |
TEST2(val, 5); //"5" is a 32-bit integer value
|
sl@0
|
711 |
val = stmt.ColumnInt(1);
|
sl@0
|
712 |
TEST2(val, KMaxTInt); //"5000000000" is a 64-bit integer, will be clamped to KMaxTInt
|
sl@0
|
713 |
val = stmt.ColumnInt(2);
|
sl@0
|
714 |
TEST2(val, KMaxTInt); //"10000000000.0" is a 64-bit double, will be rounded to the nearest 32-bit integer
|
sl@0
|
715 |
val = stmt.ColumnInt(3);
|
sl@0
|
716 |
TEST2(val, 0); //NULL column value
|
sl@0
|
717 |
val = stmt.ColumnInt(4);
|
sl@0
|
718 |
TEST2(val, 0); //NULL column value
|
sl@0
|
719 |
|
sl@0
|
720 |
err = stmt.Next();
|
sl@0
|
721 |
TEST2(err, KSqlAtRow);
|
sl@0
|
722 |
val = stmt.ColumnInt(0);
|
sl@0
|
723 |
TEST2(val, 5);
|
sl@0
|
724 |
val = stmt.ColumnInt(1);
|
sl@0
|
725 |
TEST2(val, 2000000000);
|
sl@0
|
726 |
val = stmt.ColumnInt(2);
|
sl@0
|
727 |
TEST2(val, 1000000000);
|
sl@0
|
728 |
|
sl@0
|
729 |
err = stmt.Next();
|
sl@0
|
730 |
TEST2(err, KSqlAtRow);
|
sl@0
|
731 |
val = stmt.ColumnInt(2);
|
sl@0
|
732 |
TEST2(val, KMinTInt); //"1.1234567890123456E+317" is too big and cannot fit in a 64-bit double
|
sl@0
|
733 |
|
sl@0
|
734 |
stmt.Close();
|
sl@0
|
735 |
|
sl@0
|
736 |
TheDb.Close();
|
sl@0
|
737 |
err = RSqlDatabase::Delete(KTestDbName);
|
sl@0
|
738 |
TEST2(err, KErrNone);
|
sl@0
|
739 |
}
|
sl@0
|
740 |
|
sl@0
|
741 |
/**
|
sl@0
|
742 |
@SYMTestCaseID SYSLIB-SQL-UT-3503
|
sl@0
|
743 |
@SYMTestCaseDesc Test for DEF109100: SQL, code coverage for TSqlBufRIterator is very low.
|
sl@0
|
744 |
The test creates a test table with INT32, INT64, DOUBLE, TEXT, and BINARY columns
|
sl@0
|
745 |
and inserts couple of records there. Then the test prepares a SELECT statement,
|
sl@0
|
746 |
retrieves all table rows, and to retrieve each column value, calls RSqlStatement::ColumnInt64().
|
sl@0
|
747 |
The column values are carefully chosen, so some of the ColumnInt64() calls have to round
|
sl@0
|
748 |
or clamp the returned value.
|
sl@0
|
749 |
Summary: the test checks the ColumnInt64() behaviour when the column value type is not INT64 and
|
sl@0
|
750 |
when the column value is too big or too small and cannot be presented as 64-bits integer.
|
sl@0
|
751 |
@SYMTestPriority High
|
sl@0
|
752 |
@SYMTestActions Test for DEF109100: SQL, code coverage for TSqlBufRIterator is very low.
|
sl@0
|
753 |
@SYMTestExpectedResults Test must not fail
|
sl@0
|
754 |
@SYMDEF DEF109100
|
sl@0
|
755 |
*/
|
sl@0
|
756 |
void ColumnInt64Test()
|
sl@0
|
757 |
{
|
sl@0
|
758 |
(void)RSqlDatabase::Delete(KTestDbName);
|
sl@0
|
759 |
TInt err = TheDb.Create(KTestDbName);
|
sl@0
|
760 |
TEST2(err, KErrNone);
|
sl@0
|
761 |
err = TheDb.Exec(_L("CREATE TABLE A(I32 INTEGER,I64 INTEGER,D DOUBLE,T TEXT,B BINARY)"));
|
sl@0
|
762 |
TEST(err >= 0);
|
sl@0
|
763 |
|
sl@0
|
764 |
err = TheDb.Exec(_L("INSERT INTO A VALUES(-5,-5000000000,-10000000000.0,'AAA',x'1122FF')"));
|
sl@0
|
765 |
TEST2(err, 1);
|
sl@0
|
766 |
err = TheDb.Exec(_L("INSERT INTO A VALUES(5,5000000000,10000000000.0,NULL,NULL)"));
|
sl@0
|
767 |
TEST2(err, 1);
|
sl@0
|
768 |
err = TheDb.Exec(_L("INSERT INTO A VALUES(5,2000000000,1000000000.0,NULL,NULL)"));
|
sl@0
|
769 |
TEST2(err, 1);
|
sl@0
|
770 |
err = TheDb.Exec(_L("INSERT INTO A VALUES(NULL,NULL,1.1234567890123456E+317,NULL,NULL)"));
|
sl@0
|
771 |
TEST2(err, 1);
|
sl@0
|
772 |
|
sl@0
|
773 |
RSqlStatement stmt;
|
sl@0
|
774 |
err = stmt.Prepare(TheDb, _L("SELECT I32,I64,D,T,B FROM A"));
|
sl@0
|
775 |
TEST2(err, KErrNone);
|
sl@0
|
776 |
|
sl@0
|
777 |
err = stmt.Next();
|
sl@0
|
778 |
TEST2(err, KSqlAtRow);
|
sl@0
|
779 |
TInt64 val = stmt.ColumnInt64(0);
|
sl@0
|
780 |
TEST3(val, -5); //"-5" is a 32-bit integer value
|
sl@0
|
781 |
val = stmt.ColumnInt64(1);
|
sl@0
|
782 |
TEST3(val, -5000000000LL); //"-5000000000" is a 64-bit integer
|
sl@0
|
783 |
val = stmt.ColumnInt64(2);
|
sl@0
|
784 |
TEST3(val, -10000000000LL); //"-10000000000.0" is a 64-bit double, will be rounded to the nearest 64-bit integer
|
sl@0
|
785 |
val = stmt.ColumnInt64(3);
|
sl@0
|
786 |
TEST3(val, 0); //"AAA" is a text string, cannot be converted to a 64-bit integer
|
sl@0
|
787 |
val = stmt.ColumnInt64(4);
|
sl@0
|
788 |
TEST3(val, 0); //"1122FF" is a hex binary, cannot be converted to a 64-bit integer
|
sl@0
|
789 |
|
sl@0
|
790 |
err = stmt.Next();
|
sl@0
|
791 |
TEST2(err, KSqlAtRow);
|
sl@0
|
792 |
val = stmt.ColumnInt64(0);
|
sl@0
|
793 |
TEST3(val, 5); //"5" is a 32-bit integer value
|
sl@0
|
794 |
val = stmt.ColumnInt64(1);
|
sl@0
|
795 |
TEST3(val, 5000000000LL); //"5000000000" is a 64-bit integer
|
sl@0
|
796 |
val = stmt.ColumnInt64(2);
|
sl@0
|
797 |
TEST3(val, 10000000000LL); //"10000000000.0" is a 64-bit double, will be rounded to the nearest 64-bit integer
|
sl@0
|
798 |
val = stmt.ColumnInt64(3);
|
sl@0
|
799 |
TEST3(val, 0); //NULL column value
|
sl@0
|
800 |
val = stmt.ColumnInt64(4);
|
sl@0
|
801 |
TEST3(val, 0); //NULL column value
|
sl@0
|
802 |
|
sl@0
|
803 |
err = stmt.Next();
|
sl@0
|
804 |
TEST2(err, KSqlAtRow);
|
sl@0
|
805 |
val = stmt.ColumnInt64(0);
|
sl@0
|
806 |
TEST3(val, 5);
|
sl@0
|
807 |
val = stmt.ColumnInt64(1);
|
sl@0
|
808 |
TEST3(val, 2000000000);
|
sl@0
|
809 |
val = stmt.ColumnInt64(2);
|
sl@0
|
810 |
TEST3(val, 1000000000);
|
sl@0
|
811 |
|
sl@0
|
812 |
err = stmt.Next();
|
sl@0
|
813 |
TEST2(err, KSqlAtRow);
|
sl@0
|
814 |
val = stmt.ColumnInt64(2);
|
sl@0
|
815 |
TEST3(val, KMinTInt64); //"1.1234567890123456E+317" is too big and cannot fit in a 64-bit double
|
sl@0
|
816 |
|
sl@0
|
817 |
stmt.Close();
|
sl@0
|
818 |
|
sl@0
|
819 |
TheDb.Close();
|
sl@0
|
820 |
err = RSqlDatabase::Delete(KTestDbName);
|
sl@0
|
821 |
TEST2(err, KErrNone);
|
sl@0
|
822 |
}
|
sl@0
|
823 |
|
sl@0
|
824 |
/**
|
sl@0
|
825 |
@SYMTestCaseID SYSLIB-SQL-UT-3504
|
sl@0
|
826 |
@SYMTestCaseDesc Test for DEF109100: SQL, code coverage for TSqlBufRIterator is very low.
|
sl@0
|
827 |
The test creates a test table with INT32, INT64, DOUBLE, TEXT, and BINARY columns
|
sl@0
|
828 |
and inserts couple of records there. Then the test prepares a SELECT statement,
|
sl@0
|
829 |
retrieves all table rows, and to retrieve each column value, calls RSqlStatement::ColumnReal().
|
sl@0
|
830 |
Summary: the test checks the ColumnReal() behaviour when the column value type is not DOUBLE and
|
sl@0
|
831 |
when the column value is too big or too small and cannot be presented as 64-bits double.
|
sl@0
|
832 |
@SYMTestPriority High
|
sl@0
|
833 |
@SYMTestActions Test for DEF109100: SQL, code coverage for TSqlBufRIterator is very low.
|
sl@0
|
834 |
@SYMTestExpectedResults Test must not fail
|
sl@0
|
835 |
@SYMDEF DEF109100
|
sl@0
|
836 |
*/
|
sl@0
|
837 |
void ColumnRealTest()
|
sl@0
|
838 |
{
|
sl@0
|
839 |
(void)RSqlDatabase::Delete(KTestDbName);
|
sl@0
|
840 |
TInt err = TheDb.Create(KTestDbName);
|
sl@0
|
841 |
TEST2(err, KErrNone);
|
sl@0
|
842 |
err = TheDb.Exec(_L("CREATE TABLE A(I32 INTEGER,I64 INTEGER,D DOUBLE,T TEXT,B BINARY)"));
|
sl@0
|
843 |
TEST(err >= 0);
|
sl@0
|
844 |
|
sl@0
|
845 |
err = TheDb.Exec(_L("INSERT INTO A VALUES(-5,-5000000000,-10000000000.0,'AAA',x'1122FF')"));
|
sl@0
|
846 |
TEST2(err, 1);
|
sl@0
|
847 |
err = TheDb.Exec(_L("INSERT INTO A VALUES(5,5000000000,10000000000.0,NULL,NULL)"));
|
sl@0
|
848 |
TEST2(err, 1);
|
sl@0
|
849 |
err = TheDb.Exec(_L("INSERT INTO A VALUES(5,2000000000,1000000000.0,NULL,NULL)"));
|
sl@0
|
850 |
TEST2(err, 1);
|
sl@0
|
851 |
err = TheDb.Exec(_L("INSERT INTO A VALUES(NULL,NULL,1.1234567890123456E+317,NULL,NULL)"));
|
sl@0
|
852 |
TEST2(err, 1);
|
sl@0
|
853 |
|
sl@0
|
854 |
const TReal KEpsilon = 0.000001;
|
sl@0
|
855 |
|
sl@0
|
856 |
RSqlStatement stmt;
|
sl@0
|
857 |
err = stmt.Prepare(TheDb, _L("SELECT I32,I64,D,T,B FROM A"));
|
sl@0
|
858 |
TEST2(err, KErrNone);
|
sl@0
|
859 |
|
sl@0
|
860 |
err = stmt.Next();
|
sl@0
|
861 |
TEST2(err, KSqlAtRow);
|
sl@0
|
862 |
TReal val = stmt.ColumnReal(0);
|
sl@0
|
863 |
TEST(Abs(val - (-5)) < KEpsilon);
|
sl@0
|
864 |
val = stmt.ColumnReal(1);
|
sl@0
|
865 |
TEST(Abs(val - (-5000000000LL)) < KEpsilon);
|
sl@0
|
866 |
val = stmt.ColumnReal(2);
|
sl@0
|
867 |
TEST(Abs(val - (-10000000000LL)) < KEpsilon);
|
sl@0
|
868 |
val = stmt.ColumnReal(3);
|
sl@0
|
869 |
TEST(Abs(val) < 0.0001); //"AAA" is a text string, cannot be converted to a 64-bit double
|
sl@0
|
870 |
val = stmt.ColumnReal(4);
|
sl@0
|
871 |
TEST(Abs(val) < 0.0001); //"1122FF" is a hex binary, cannot be converted to a 64-bit double
|
sl@0
|
872 |
|
sl@0
|
873 |
err = stmt.Next();
|
sl@0
|
874 |
TEST2(err, KSqlAtRow);
|
sl@0
|
875 |
val = stmt.ColumnReal(0);
|
sl@0
|
876 |
TEST(Abs(val - 5) < KEpsilon);
|
sl@0
|
877 |
val = stmt.ColumnReal(1);
|
sl@0
|
878 |
TEST(Abs(val - 5000000000LL) < KEpsilon);
|
sl@0
|
879 |
val = stmt.ColumnReal(2);
|
sl@0
|
880 |
TEST(Abs(val - 10000000000LL) < KEpsilon);
|
sl@0
|
881 |
val = stmt.ColumnReal(3);
|
sl@0
|
882 |
TEST(Abs(val) < KEpsilon); //NULL column value
|
sl@0
|
883 |
val = stmt.ColumnReal(4);
|
sl@0
|
884 |
TEST(Abs(val) < KEpsilon); //NULL column value
|
sl@0
|
885 |
|
sl@0
|
886 |
err = stmt.Next();
|
sl@0
|
887 |
TEST2(err, KSqlAtRow);
|
sl@0
|
888 |
val = stmt.ColumnReal(0);
|
sl@0
|
889 |
TEST(Abs(val - 5) < KEpsilon);
|
sl@0
|
890 |
val = stmt.ColumnReal(1);
|
sl@0
|
891 |
TEST(Abs(val - 2000000000) < KEpsilon);
|
sl@0
|
892 |
val = stmt.ColumnReal(2);
|
sl@0
|
893 |
TEST(Abs(val - 1000000000) < KEpsilon);
|
sl@0
|
894 |
|
sl@0
|
895 |
err = stmt.Next();
|
sl@0
|
896 |
TEST2(err, KSqlAtRow);
|
sl@0
|
897 |
val = stmt.ColumnReal(2);
|
sl@0
|
898 |
TEST(Math::IsInfinite(val)); //"1.1234567890123456E+317" is too big and cannot fit in a 64-bit double
|
sl@0
|
899 |
|
sl@0
|
900 |
stmt.Close();
|
sl@0
|
901 |
|
sl@0
|
902 |
TheDb.Close();
|
sl@0
|
903 |
err = RSqlDatabase::Delete(KTestDbName);
|
sl@0
|
904 |
TEST2(err, KErrNone);
|
sl@0
|
905 |
}
|
sl@0
|
906 |
|
sl@0
|
907 |
/**
|
sl@0
|
908 |
@SYMTestCaseID SYSLIB-SQL-UT-3505
|
sl@0
|
909 |
@SYMTestCaseDesc Test for DEF109100: SQL, code coverage for TSqlBufRIterator is very low.
|
sl@0
|
910 |
The test creates a test table with INT32, INT64, DOUBLE, TEXT, and BINARY columns
|
sl@0
|
911 |
and inserts a record there. Then the test prepares a SELECT statement,
|
sl@0
|
912 |
retrieves all table rows, and to retrieve each column value, calls RSqlStatement::ColumnText().
|
sl@0
|
913 |
Summary: the test checks the ColumnText() behaviour when the column value type is not TEXT.
|
sl@0
|
914 |
(In all non-TEXT cases the ,ethod is expected to return KNullDesC8)
|
sl@0
|
915 |
@SYMTestPriority High
|
sl@0
|
916 |
@SYMTestActions Test for DEF109100: SQL, code coverage for TSqlBufRIterator is very low.
|
sl@0
|
917 |
@SYMTestExpectedResults Test must not fail
|
sl@0
|
918 |
@SYMDEF DEF109100
|
sl@0
|
919 |
*/
|
sl@0
|
920 |
void ColumnTextTest()
|
sl@0
|
921 |
{
|
sl@0
|
922 |
(void)RSqlDatabase::Delete(KTestDbName);
|
sl@0
|
923 |
TInt err = TheDb.Create(KTestDbName);
|
sl@0
|
924 |
TEST2(err, KErrNone);
|
sl@0
|
925 |
err = TheDb.Exec(_L("CREATE TABLE A(I32 INTEGER,I64 INTEGER,D DOUBLE,T TEXT,B BINARY)"));
|
sl@0
|
926 |
TEST(err >= 0);
|
sl@0
|
927 |
|
sl@0
|
928 |
err = TheDb.Exec(_L("INSERT INTO A VALUES(-5,-5000000000,-10000000000.0,'AAA',x'1122FF')"));
|
sl@0
|
929 |
TEST2(err, 1);
|
sl@0
|
930 |
|
sl@0
|
931 |
RSqlStatement stmt;
|
sl@0
|
932 |
err = stmt.Prepare(TheDb, _L("SELECT I32,I64,D,T,B FROM A"));
|
sl@0
|
933 |
TEST2(err, KErrNone);
|
sl@0
|
934 |
|
sl@0
|
935 |
err = stmt.Next();
|
sl@0
|
936 |
TEST2(err, KSqlAtRow);
|
sl@0
|
937 |
TPtrC val;
|
sl@0
|
938 |
err = stmt.ColumnText(0, val);
|
sl@0
|
939 |
TEST2(err, KErrNone);
|
sl@0
|
940 |
TEST(val == KNullDesC);
|
sl@0
|
941 |
err = stmt.ColumnText(1, val);
|
sl@0
|
942 |
TEST2(err, KErrNone);
|
sl@0
|
943 |
TEST(val == KNullDesC);
|
sl@0
|
944 |
err = stmt.ColumnText(2, val);
|
sl@0
|
945 |
TEST2(err, KErrNone);
|
sl@0
|
946 |
TEST(val == KNullDesC);
|
sl@0
|
947 |
err = stmt.ColumnText(3, val);
|
sl@0
|
948 |
TEST2(err, KErrNone);
|
sl@0
|
949 |
TEST2(val.Length(), 3);
|
sl@0
|
950 |
TEST(val == _L("AAA"));
|
sl@0
|
951 |
err = stmt.ColumnText(4, val);
|
sl@0
|
952 |
TEST2(err, KErrNone);
|
sl@0
|
953 |
TEST(val == KNullDesC);
|
sl@0
|
954 |
|
sl@0
|
955 |
stmt.Close();
|
sl@0
|
956 |
|
sl@0
|
957 |
TheDb.Close();
|
sl@0
|
958 |
err = RSqlDatabase::Delete(KTestDbName);
|
sl@0
|
959 |
TEST2(err, KErrNone);
|
sl@0
|
960 |
}
|
sl@0
|
961 |
|
sl@0
|
962 |
/**
|
sl@0
|
963 |
@SYMTestCaseID SYSLIB-SQL-UT-3506
|
sl@0
|
964 |
@SYMTestCaseDesc Test for DEF109100: SQL, code coverage for TSqlBufRIterator is very low.
|
sl@0
|
965 |
The test creates a test table with INT32, INT64, DOUBLE, TEXT, and BINARY columns
|
sl@0
|
966 |
and inserts a record there. Then the test prepares a SELECT statement,
|
sl@0
|
967 |
retrieves all table rows, and to retrieve each column value, calls RSqlStatement::ColumnBinary().
|
sl@0
|
968 |
Summary: the test checks the ColumnBinary() behaviour when the column value type is not BINARY.
|
sl@0
|
969 |
(In all non-BINARY cases the method is expected to return KNullDesC8)
|
sl@0
|
970 |
@SYMTestPriority High
|
sl@0
|
971 |
@SYMTestActions Test for DEF109100: SQL, code coverage for TSqlBufRIterator is very low.
|
sl@0
|
972 |
@SYMTestExpectedResults Test must not fail
|
sl@0
|
973 |
@SYMDEF DEF109100
|
sl@0
|
974 |
*/
|
sl@0
|
975 |
void ColumnBinaryTest()
|
sl@0
|
976 |
{
|
sl@0
|
977 |
(void)RSqlDatabase::Delete(KTestDbName);
|
sl@0
|
978 |
TInt err = TheDb.Create(KTestDbName);
|
sl@0
|
979 |
TEST2(err, KErrNone);
|
sl@0
|
980 |
err = TheDb.Exec(_L("CREATE TABLE A(I32 INTEGER,I64 INTEGER,D DOUBLE,T TEXT,B BINARY)"));
|
sl@0
|
981 |
TEST(err >= 0);
|
sl@0
|
982 |
|
sl@0
|
983 |
err = TheDb.Exec(_L("INSERT INTO A VALUES(-5,-5000000000,-10000000000.0,'AAA',x'1122FF')"));
|
sl@0
|
984 |
TEST2(err, 1);
|
sl@0
|
985 |
|
sl@0
|
986 |
RSqlStatement stmt;
|
sl@0
|
987 |
err = stmt.Prepare(TheDb, _L("SELECT I32,I64,D,T,B FROM A"));
|
sl@0
|
988 |
TEST2(err, KErrNone);
|
sl@0
|
989 |
|
sl@0
|
990 |
err = stmt.Next();
|
sl@0
|
991 |
TEST2(err, KSqlAtRow);
|
sl@0
|
992 |
TPtrC8 val;
|
sl@0
|
993 |
err = stmt.ColumnBinary(0, val);
|
sl@0
|
994 |
TEST2(err, KErrNone);
|
sl@0
|
995 |
TEST(val == KNullDesC8);
|
sl@0
|
996 |
err = stmt.ColumnBinary(1, val);
|
sl@0
|
997 |
TEST2(err, KErrNone);
|
sl@0
|
998 |
TEST(val == KNullDesC8);
|
sl@0
|
999 |
err = stmt.ColumnBinary(2, val);
|
sl@0
|
1000 |
TEST2(err, KErrNone);
|
sl@0
|
1001 |
TEST(val == KNullDesC8);
|
sl@0
|
1002 |
err = stmt.ColumnBinary(3, val);
|
sl@0
|
1003 |
TEST2(err, KErrNone);
|
sl@0
|
1004 |
TEST(val == KNullDesC8);
|
sl@0
|
1005 |
err = stmt.ColumnBinary(4, val);
|
sl@0
|
1006 |
TEST2(err, KErrNone);
|
sl@0
|
1007 |
TEST2(val.Length(), 3);
|
sl@0
|
1008 |
TEST(val[0] == 0x11);
|
sl@0
|
1009 |
TEST(val[1] == 0x22);
|
sl@0
|
1010 |
TEST(val[2] == 0xFF);
|
sl@0
|
1011 |
|
sl@0
|
1012 |
stmt.Close();
|
sl@0
|
1013 |
|
sl@0
|
1014 |
TheDb.Close();
|
sl@0
|
1015 |
err = RSqlDatabase::Delete(KTestDbName);
|
sl@0
|
1016 |
TEST2(err, KErrNone);
|
sl@0
|
1017 |
}
|
sl@0
|
1018 |
|
sl@0
|
1019 |
void DoTestsL()
|
sl@0
|
1020 |
{
|
sl@0
|
1021 |
TheTest.Start(_L(" @SYMTestCaseID:SYSLIB-SQL-CT-1611 E011 numeric data types test "));
|
sl@0
|
1022 |
NumericDataTypesTest();
|
sl@0
|
1023 |
|
sl@0
|
1024 |
TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-SQL-CT-1630 Built-in functions test "));
|
sl@0
|
1025 |
BuiltInFunctionsTest();
|
sl@0
|
1026 |
|
sl@0
|
1027 |
TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-SQL-CT-1632 \"Attach database\" test "));
|
sl@0
|
1028 |
AttachDatabaseTest();
|
sl@0
|
1029 |
|
sl@0
|
1030 |
TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-SQL-UT-3502 \"RSqlStatement::ColumnInt()\" test "));
|
sl@0
|
1031 |
ColumnIntTest();
|
sl@0
|
1032 |
|
sl@0
|
1033 |
TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-SQL-UT-3503 \"RSqlStatement::ColumnInt64()\" test "));
|
sl@0
|
1034 |
ColumnInt64Test();
|
sl@0
|
1035 |
|
sl@0
|
1036 |
TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-SQL-UT-3504 \"RSqlStatement::ColumnReal()\" test "));
|
sl@0
|
1037 |
ColumnRealTest();
|
sl@0
|
1038 |
|
sl@0
|
1039 |
TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-SQL-UT-3505 \"RSqlStatement::ColumnText()\" test "));
|
sl@0
|
1040 |
ColumnTextTest();
|
sl@0
|
1041 |
|
sl@0
|
1042 |
TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-SQL-UT-3506 \"RSqlStatement::ColumnBinary()\" test "));
|
sl@0
|
1043 |
ColumnBinaryTest();
|
sl@0
|
1044 |
}
|
sl@0
|
1045 |
|
sl@0
|
1046 |
TInt E32Main()
|
sl@0
|
1047 |
{
|
sl@0
|
1048 |
TheTest.Title();
|
sl@0
|
1049 |
|
sl@0
|
1050 |
CTrapCleanup* tc = CTrapCleanup::New();
|
sl@0
|
1051 |
|
sl@0
|
1052 |
__UHEAP_MARK;
|
sl@0
|
1053 |
|
sl@0
|
1054 |
CreateTestDir();
|
sl@0
|
1055 |
DeleteTestFiles();
|
sl@0
|
1056 |
TRAPD(err, DoTestsL());
|
sl@0
|
1057 |
DeleteTestFiles();
|
sl@0
|
1058 |
TEST2(err, KErrNone);
|
sl@0
|
1059 |
|
sl@0
|
1060 |
__UHEAP_MARKEND;
|
sl@0
|
1061 |
|
sl@0
|
1062 |
TheTest.End();
|
sl@0
|
1063 |
TheTest.Close();
|
sl@0
|
1064 |
|
sl@0
|
1065 |
delete tc;
|
sl@0
|
1066 |
|
sl@0
|
1067 |
User::Heap().Check();
|
sl@0
|
1068 |
return KErrNone;
|
sl@0
|
1069 |
}
|