persistentstorage/sql/TEST/t_sqlsecurity4.cpp
changeset 55 44f437012c90
parent 15 3eacc0623088
equal deleted inserted replaced
51:7d4490026038 55:44f437012c90
    66 void Check1(TInt aValue, TInt aLine)
    66 void Check1(TInt aValue, TInt aLine)
    67 	{
    67 	{
    68 	if(!aValue)
    68 	if(!aValue)
    69 		{
    69 		{
    70 		RestoreOriginalDb();
    70 		RestoreOriginalDb();
    71 		RDebug::Print(_L("*** Line %d\r\n"), aLine);
    71 		TheTest.Printf(_L("*** Line %d\r\n"), aLine);
    72 		TheTest(EFalse, aLine);
    72 		TheTest(EFalse, aLine);
    73 		}
    73 		}
    74 	}
    74 	}
    75 void Check2(TInt aValue, TInt aExpected, TInt aLine)
    75 void Check2(TInt aValue, TInt aExpected, TInt aLine)
    76 	{
    76 	{
    77 	if(aValue != aExpected)
    77 	if(aValue != aExpected)
    78 		{
    78 		{
    79 		RestoreOriginalDb();
    79 		RestoreOriginalDb();
    80 		RDebug::Print(_L("*** Line %d, Expected error: %d, got: %d\r\n"), aLine, aExpected, aValue);
    80 		TheTest.Printf(_L("*** Line %d, Expected error: %d, got: %d\r\n"), aLine, aExpected, aValue);
    81 		TheTest(EFalse, aLine);
    81 		TheTest(EFalse, aLine);
    82 		}
    82 		}
    83 	}
    83 	}
    84 #define TEST(arg) ::Check1((arg), __LINE__)
    84 #define TEST(arg) ::Check1((arg), __LINE__)
    85 #define TEST2(aValue, aExpected) ::Check2(aValue, aExpected, __LINE__)
    85 #define TEST2(aValue, aExpected) ::Check2(aValue, aExpected, __LINE__)
   218 	err = stmt.DeclaredColumnType(0, colType);
   218 	err = stmt.DeclaredColumnType(0, colType);
   219 	TEST2(err, KErrNone);
   219 	TEST2(err, KErrNone);
   220 	TEST2(colType, ESqlInt);
   220 	TEST2(colType, ESqlInt);
   221 	err = stmt.Next();
   221 	err = stmt.Next();
   222 	TEST2(err, KSqlAtRow);
   222 	TEST2(err, KSqlAtRow);
   223 	RDebug::Print(_L("Value=%d\r\n"), stmt.ColumnInt(0));
   223 	TheTest.Printf(_L("Value=%d\r\n"), stmt.ColumnInt(0));
   224 	err = stmt.Next();
   224 	err = stmt.Next();
   225 	TEST2(err, KSqlAtRow);
   225 	TEST2(err, KSqlAtRow);
   226 	RDebug::Print(_L("Value=%d\r\n"), stmt.ColumnInt(0));
   226 	TheTest.Printf(_L("Value=%d\r\n"), stmt.ColumnInt(0));
   227 	stmt.Close();
   227 	stmt.Close();
   228 	//Attempt to read the system data
   228 	//Attempt to read the system data
   229 	err = stmt.Prepare(TheDb, _L("SELECT * FROM SQLITE_MASTER"));
   229 	err = stmt.Prepare(TheDb, _L("SELECT * FROM SQLITE_MASTER"));
   230 	TEST2(err, KErrNone);
   230 	TEST2(err, KErrNone);
   231 	err = stmt.Next();
   231 	err = stmt.Next();
   232 	TEST2(err, KSqlAtRow);
   232 	TEST2(err, KSqlAtRow);
   233 	TPtrC p;
   233 	TPtrC p;
   234 	err = stmt.ColumnText(0, p);
   234 	err = stmt.ColumnText(0, p);
   235 	TEST2(err, KErrNone);
   235 	TEST2(err, KErrNone);
   236 	RDebug::Print(_L("Value=%S\r\n"), &p);
   236 	TheTest.Printf(_L("Value=%S\r\n"), &p);
   237 	stmt.Close();
   237 	stmt.Close();
   238 	
   238 	
   239 	NonSecureDbTest();
   239 	NonSecureDbTest();
   240 	
   240 	
   241 	TheDb.Close();
   241 	TheDb.Close();