persistentstorage/sql/TEST/t_sqlscalarfullselect.cpp
branchRCL_3
changeset 15 fcc16690f446
parent 0 08ec8eefde2f
equal deleted inserted replaced
14:04ec7606545c 15:fcc16690f446
     1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
   319 
   319 
   320 	//Close database, delete database file.
   320 	//Close database, delete database file.
   321 	DestroyTestDb(db);
   321 	DestroyTestDb(db);
   322 	}
   322 	}
   323 
   323 
       
   324 /**
       
   325 @SYMTestCaseID          PDS-SQL-CT-4204
       
   326 @SYMTestCaseDesc        TSqlScalarFullSelectQuery - border test.
       
   327 @SYMTestPriority        High
       
   328 @SYMTestActions         The test checks some border test cases such as:
       
   329 						- retrieving NULL column as integer;
       
   330 						- retrieving NULL column as 64-bit integer;
       
   331 						- retrieving NULL column as TReal;
       
   332 						- retrieving column value smaller than KMinTInt, as integer;
       
   333 						- retrieving column value bigger than KMaxTInt, as integer;
       
   334 @SYMTestExpectedResults Test must not fail
       
   335 */  
       
   336 void ScalarFullSelectBorderTest()
       
   337 	{
       
   338 	(void)RSqlDatabase::Delete(KTestDatabase1);
       
   339 	RSqlDatabase db;
       
   340 	TInt rc = db.Create(KTestDatabase1);
       
   341 	TEST2(rc, KErrNone);
       
   342 	rc = db.Exec(_L("CREATE TABLE A(F1 INTEGER NULL, F2 INTEGER NULL, F3 FLOAT NULL, F4 TEXT NULL, F5 BLOB NULL)"));
       
   343 	TEST(rc >= 0);
       
   344 	
       
   345 	TSqlScalarFullSelectQuery q(db);
       
   346 
       
   347 	//Insert one record. Bigger than KMaxTInt F1 column value. Smaller than KMinTInt F2 column value.
       
   348 	rc = db.Exec(_L("INSERT INTO A(F1,F2,F4) VALUES(5000000000,-5000000000,'aljhsfdlgefberveurfgvefkjgs;kjfgs;kjfsd')"));
       
   349 	TEST2(rc, 1);
       
   350 	//Select NULL column value as int.
       
   351 	TInt res = -1;
       
   352 	TRAP(rc, res = q.SelectIntL(_L("SELECT F5 FROM A")));
       
   353 	TEST2(rc, KErrNone);
       
   354 	TEST2(res, 0);
       
   355 	//Select NULL column value as int64.
       
   356 	res = -1;
       
   357 	TRAP(rc, res = q.SelectInt64L(_L("SELECT F5 FROM A")));
       
   358 	TEST2(rc, KErrNone);
       
   359 	TEST2(res, 0);
       
   360 	//Select NULL column value as TReal.
       
   361 	TReal res2 = -1.0;
       
   362 	TRAP(rc, res2 = q.SelectRealL(_L("SELECT F5 FROM A")));
       
   363 	TEST2(rc, KErrNone);
       
   364 	TEST(Abs(res2) < 0.000001);
       
   365 	//Select NULL column value as text.
       
   366 	TBuf<10> text;
       
   367 	TRAP(rc, res = q.SelectTextL(_L("SELECT F5 FROM A"), text));
       
   368 	TEST2(rc, KErrNone);
       
   369 	TEST2(res, 0);
       
   370 	TEST2(text.Length(), 0);
       
   371 	//Select NULL column value as binary.
       
   372 	TBuf8<10> data;
       
   373 	TRAP(rc, res = q.SelectBinaryL(_L("SELECT F5 FROM A"), data));
       
   374 	TEST2(rc, KErrNone);
       
   375 	TEST2(res, 0);
       
   376 	TEST2(data.Length(), 0);
       
   377 	//Select column value bigger than KMaxTInt, as int.
       
   378 	res = -1;
       
   379 	TRAP(rc, res = q.SelectIntL(_L("SELECT F1 FROM A")));
       
   380 	TEST2(rc, KErrNone);
       
   381 	TEST2(res, KMaxTInt);
       
   382 	//Select column value smaller than KMinTInt, as int.
       
   383 	res = -1;
       
   384 	TRAP(rc, res = q.SelectIntL(_L("SELECT F2 FROM A")));
       
   385 	TEST2(rc, KErrNone);
       
   386 	TEST2(res, KMinTInt);
       
   387 
       
   388 	db.Close();
       
   389 	(void)RSqlDatabase::Delete(KTestDatabase1);
       
   390 	}
       
   391 	
       
   392 
   324 void DoTestsL()
   393 void DoTestsL()
   325 	{
   394 	{
   326 	TheTest.Start(_L(" @SYMTestCaseID:SYSLIB-SQL-CT-1809 Scalar fullselect test. 16-bit SQL "));
   395 	TheTest.Start(_L(" @SYMTestCaseID:SYSLIB-SQL-CT-1809 Scalar fullselect test. 16-bit SQL "));
   327 	ScalarFullSelectTestL< TBuf16<100> >();
   396 	ScalarFullSelectTestL< TBuf16<100> >();
   328 
   397 
   332 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-SQL-CT-1810 Scalar fullselect - negative test. 16-bit SQL "));
   401 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-SQL-CT-1810 Scalar fullselect - negative test. 16-bit SQL "));
   333 	ScalarFullSelectNegativeTestL< TBuf16<100> >();
   402 	ScalarFullSelectNegativeTestL< TBuf16<100> >();
   334 
   403 
   335 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-SQL-CT-1810 Scalar fullselect - negative test. 8-bit SQL "));
   404 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-SQL-CT-1810 Scalar fullselect - negative test. 8-bit SQL "));
   336 	ScalarFullSelectNegativeTestL< TBuf8<100> >();
   405 	ScalarFullSelectNegativeTestL< TBuf8<100> >();
       
   406 	
       
   407 	TheTest.Next(_L(" @SYMTestCaseID:PDS-SQL-CT-4204 Scalar fullselect - border cases "));
       
   408 	ScalarFullSelectBorderTest();
   337 	}
   409 	}
   338 
   410 
   339 TInt E32Main()
   411 TInt E32Main()
   340 	{
   412 	{
   341 	TheTest.Title();
   413 	TheTest.Title();