persistentstorage/sql/TEST/t_sqlcorrupt.cpp
changeset 55 44f437012c90
parent 51 7d4490026038
equal deleted inserted replaced
51:7d4490026038 55:44f437012c90
    20 #include "sqlite3.h"
    20 #include "sqlite3.h"
    21 #include "SqliteSymbian.h"
    21 #include "SqliteSymbian.h"
    22 
    22 
    23 ///////////////////////////////////////////////////////////////////////////////////////
    23 ///////////////////////////////////////////////////////////////////////////////////////
    24 
    24 
       
    25 //In order to be able to compile the test, the following variables are defined (used inside the OS porting layer, when _SQLPROFILER macro is defined)
       
    26 #ifdef _SQLPROFILER
       
    27 TInt TheSqlSrvProfilerFileRead = 0;
       
    28 TInt TheSqlSrvProfilerFileWrite = 0;
       
    29 TInt TheSqlSrvProfilerFileSync = 0;
       
    30 TInt TheSqlSrvProfilerFileSetSize = 0;
       
    31 #endif
       
    32 
    25 RSqlDatabase TheDb;
    33 RSqlDatabase TheDb;
    26 RTest TheTest(_L("t_sqlcorrupt test"));
    34 RTest TheTest(_L("t_sqlcorrupt test"));
    27 
    35 
    28 _LIT(KTestDir, "c:\\test\\");
    36 _LIT(KTestDir, "c:\\test\\");
    29 
    37 
    50 void Check1(TInt aValue, TInt aLine)
    58 void Check1(TInt aValue, TInt aLine)
    51 	{
    59 	{
    52 	if(!aValue)
    60 	if(!aValue)
    53 		{
    61 		{
    54 		DestroyTestEnv();
    62 		DestroyTestEnv();
    55 		RDebug::Print(_L("*** Boolean expression evaluated to false. Line %d\r\n"), aLine);
    63 		TheTest.Printf(_L("*** Expression evaluated to false. Line %d\r\n"), aLine);
    56 		TheTest(EFalse, aLine);
    64 		TheTest(EFalse, aLine);
    57 		}
    65 		}
    58 	}
    66 	}
    59 void Check2(TInt aValue, TInt aExpected, TInt aLine)
    67 void Check2(TInt aValue, TInt aExpected, TInt aLine)
    60 	{
    68 	{
    61 	if(aValue != aExpected)
    69 	if(aValue != aExpected)
    62 		{
    70 		{
    63 		DestroyTestEnv();
    71 		DestroyTestEnv();
    64 		RDebug::Print(_L("*** Line %d, Expected error: %d, got: %d\r\n"), aLine, aExpected, aValue);
    72 		TheTest.Printf(_L("*** Line %d, Expected error: %d, got: %d\r\n"), aLine, aExpected, aValue);
    65 		TheTest(EFalse, aLine);
    73 		TheTest(EFalse, aLine);
    66 		}
    74 		}
    67 	}
    75 	}
    68 #define TEST(arg) ::Check1((arg), __LINE__)
    76 #define TEST(arg) ::Check1((arg), __LINE__)
    69 #define TEST2(aValue, aExpected) ::Check2(aValue, aExpected, __LINE__)
    77 #define TEST2(aValue, aExpected) ::Check2(aValue, aExpected, __LINE__)
   440 	}
   448 	}
   441 
   449 
   442 TInt E32Main()
   450 TInt E32Main()
   443 	{
   451 	{
   444 	TheTest.Title();
   452 	TheTest.Title();
   445 	
   453 
   446 	CTrapCleanup* tc = CTrapCleanup::New();
   454 	CTrapCleanup* tc = CTrapCleanup::New();
   447 	TheTest(tc != NULL);
   455 	TheTest(tc != NULL);
   448 	
   456 	
   449 	__UHEAP_MARK;
   457 	__UHEAP_MARK;
   450 		
   458