persistentstorage/sql/TEST/t_sqlsecurity5.cpp
changeset 55 44f437012c90
parent 15 3eacc0623088
equal deleted inserted replaced
51:7d4490026038 55:44f437012c90
    75 	{
    75 	{
    76 	if(!aValue)
    76 	if(!aValue)
    77 		{
    77 		{
    78 		DeleteTestDb2();
    78 		DeleteTestDb2();
    79 		RestoreOriginalDb();
    79 		RestoreOriginalDb();
    80 		RDebug::Print(_L("*** Line %d\r\n"), aLine);
    80 		TheTest.Printf(_L("*** Line %d. Expression evaluated to false\r\n"), aLine);
    81 		TheTest(EFalse, aLine);
    81 		TheTest(EFalse, aLine);
    82 		}
    82 		}
    83 	}
    83 	}
    84 void Check2(TInt aValue, TInt aExpected, TInt aLine)
    84 void Check2(TInt aValue, TInt aExpected, TInt aLine)
    85 	{
    85 	{
    86 	if(aValue != aExpected)
    86 	if(aValue != aExpected)
    87 		{
    87 		{
    88 		DeleteTestDb2();
    88 		DeleteTestDb2();
    89 		RestoreOriginalDb();
    89 		RestoreOriginalDb();
    90 		RDebug::Print(_L("*** Line %d, Expected error: %d, got: %d\r\n"), aLine, aExpected, aValue);
    90 		TheTest.Printf(_L("*** Line %d, Expected error: %d, got: %d\r\n"), aLine, aExpected, aValue);
    91 		TheTest(EFalse, aLine);
    91 		TheTest(EFalse, aLine);
    92 		}
    92 		}
    93 	}
    93 	}
    94 #define TEST(arg) ::Check1((arg), __LINE__)
    94 #define TEST(arg) ::Check1((arg), __LINE__)
    95 #define TEST2(aValue, aExpected) ::Check2(aValue, aExpected, __LINE__)
    95 #define TEST2(aValue, aExpected) ::Check2(aValue, aExpected, __LINE__)
   187 	err = stmt.DeclaredColumnType(0, colType);
   187 	err = stmt.DeclaredColumnType(0, colType);
   188 	TEST2(err, KErrNone);
   188 	TEST2(err, KErrNone);
   189 	TEST2(colType, ESqlInt);
   189 	TEST2(colType, ESqlInt);
   190 	err = stmt.Next();
   190 	err = stmt.Next();
   191 	TEST2(err, KSqlAtRow);
   191 	TEST2(err, KSqlAtRow);
   192 	RDebug::Print(_L("Value=%d\r\n"), stmt.ColumnInt(0));
   192 	TheTest.Printf(_L("Value=%d\r\n"), stmt.ColumnInt(0));
   193 	err = stmt.Next();
   193 	err = stmt.Next();
   194 	TEST2(err, KSqlAtRow);
   194 	TEST2(err, KSqlAtRow);
   195 	RDebug::Print(_L("Value=%d\r\n"), stmt.ColumnInt(0));
   195 	TheTest.Printf(_L("Value=%d\r\n"), stmt.ColumnInt(0));
   196 	stmt.Close();
   196 	stmt.Close();
   197 	//Attempt to read the system data
   197 	//Attempt to read the system data
   198 	err = stmt.Prepare(TheDb, _L("SELECT * FROM SQLITE_MASTER"));
   198 	err = stmt.Prepare(TheDb, _L("SELECT * FROM SQLITE_MASTER"));
   199 	TEST2(err, KErrNone);
   199 	TEST2(err, KErrNone);
   200 	err = stmt.Next();
   200 	err = stmt.Next();
   201 	TEST2(err, KSqlAtRow);
   201 	TEST2(err, KSqlAtRow);
   202 	TPtrC p;
   202 	TPtrC p;
   203 	err = stmt.ColumnText(0, p);
   203 	err = stmt.ColumnText(0, p);
   204 	TEST2(err, KErrNone);
   204 	TEST2(err, KErrNone);
   205 	RDebug::Print(_L("Value=%S\r\n"), &p);
   205 	TheTest.Printf(_L("Value=%S\r\n"), &p);
   206 	//
   206 	//
   207 	stmt.Close();
   207 	stmt.Close();
   208 	TheDb.Close();
   208 	TheDb.Close();
   209 	}
   209 	}
   210 
   210