persistentstorage/sql/TEST/t_sqloom6.cpp
changeset 55 44f437012c90
parent 17 55f2396f6d25
equal deleted inserted replaced
51:7d4490026038 55:44f437012c90
    63 void Check(TInt aValue, TInt aLine)
    63 void Check(TInt aValue, TInt aLine)
    64 	{
    64 	{
    65 	if(!aValue)
    65 	if(!aValue)
    66 		{
    66 		{
    67 		DestroyTestEnv();
    67 		DestroyTestEnv();
    68 		RDebug::Print(_L("*** Expresssion evaluated to false\r\n"));
    68 		TheTest.Printf(_L("*** Expresssion evaluated to false\r\n"));
    69 		TheTest(EFalse, aLine);
    69 		TheTest(EFalse, aLine);
    70 		}
    70 		}
    71 	}
    71 	}
    72 void Check(TInt aValue, TInt aExpected, TInt aLine)
    72 void Check(TInt aValue, TInt aExpected, TInt aLine)
    73 	{
    73 	{
    74 	if(aValue != aExpected)
    74 	if(aValue != aExpected)
    75 		{
    75 		{
    76 		DestroyTestEnv();
    76 		DestroyTestEnv();
    77 		RDebug::Print(_L("*** Expected error: %d, got: %d\r\n"), aExpected, aValue);
    77 		TheTest.Printf(_L("*** Expected error: %d, got: %d\r\n"), aExpected, aValue);
    78 		TheTest(EFalse, aLine);
    78 		TheTest(EFalse, aLine);
    79 		}
    79 		}
    80 	}
    80 	}
    81 #define TEST(arg) ::Check((arg), __LINE__)
    81 #define TEST(arg) ::Check((arg), __LINE__)
    82 #define TEST2(aValue, aExpected) ::Check(aValue, aExpected, __LINE__)
    82 #define TEST2(aValue, aExpected) ::Check(aValue, aExpected, __LINE__)
   197     CreateTestDb(KDbFile);//Creates UTF8 encoded database with one table with one record.
   197     CreateTestDb(KDbFile);//Creates UTF8 encoded database with one table with one record.
   198     
   198     
   199     TInt err = TheDb.Open(KDbFile);
   199     TInt err = TheDb.Open(KDbFile);
   200     TEST2(err, KErrNone);
   200     TEST2(err, KErrNone);
   201     
   201     
       
   202     TPtrC name;
   202     TInt failingAllocationNo = 0;
   203     TInt failingAllocationNo = 0;
   203     err = KErrNoMemory;
   204     err = KErrNoMemory;
   204     while(err == KErrNoMemory)
   205     while(err == KErrNoMemory)
   205         {
   206         {
   206         TheTest.Printf(_L(" %d"), ++failingAllocationNo);
   207         TheTest.Printf(_L(" %d"), ++failingAllocationNo);
   210         if(err != KErrNone)
   211         if(err != KErrNone)
   211             {
   212             {
   212             goto LabelOomPostStep;
   213             goto LabelOomPostStep;
   213             }
   214             }
   214         
   215         
   215         TPtrC name;
       
   216         err = TheStmt.ColumnName(0, name);
   216         err = TheStmt.ColumnName(0, name);
   217         if(err != KErrNone)
   217         if(err != KErrNone)
   218             {
   218             {
   219             goto LabelStmtClose;
   219             goto LabelStmtClose;
   220             }
   220             }
   280     CreateTestDb(KDbFile);//Creates UTF8 encoded database with one table with one record.
   280     CreateTestDb(KDbFile);//Creates UTF8 encoded database with one table with one record.
   281     
   281     
   282     TInt err = TheDb.Open(KDbFile);
   282     TInt err = TheDb.Open(KDbFile);
   283     TEST2(err, KErrNone);
   283     TEST2(err, KErrNone);
   284     
   284     
       
   285     TPtrC name;
   285     TInt failingAllocationNo = 0;
   286     TInt failingAllocationNo = 0;
   286     err = KErrNoMemory;
   287     err = KErrNoMemory;
   287     while(err == KErrNoMemory)
   288     while(err == KErrNoMemory)
   288         {
   289         {
   289         TheTest.Printf(_L(" %d"), ++failingAllocationNo);
   290         TheTest.Printf(_L(" %d"), ++failingAllocationNo);
   293         if(err != KErrNone)
   294         if(err != KErrNone)
   294             {
   295             {
   295             goto LabelOomPostStep;
   296             goto LabelOomPostStep;
   296             }
   297             }
   297         
   298         
   298         TPtrC name;
       
   299         err = TheStmt.ParameterName(0, name);
   299         err = TheStmt.ParameterName(0, name);
   300         if(err != KErrNone)
   300         if(err != KErrNone)
   301             {
   301             {
   302             goto LabelStmtClose;
   302             goto LabelStmtClose;
   303             }
   303             }
   363     CreateTestDb(KDbFile);//Creates UTF8 encoded database with one table with one record.
   363     CreateTestDb(KDbFile);//Creates UTF8 encoded database with one table with one record.
   364     
   364     
   365     TInt err = TheDb.Open(KDbFile);
   365     TInt err = TheDb.Open(KDbFile);
   366     TEST2(err, KErrNone);
   366     TEST2(err, KErrNone);
   367     
   367     
       
   368     TPtrC data;
   368     TInt failingAllocationNo = 0;
   369     TInt failingAllocationNo = 0;
   369     err = KErrNoMemory;
   370     err = KErrNoMemory;
   370     while(err == KErrNoMemory)
   371     while(err == KErrNoMemory)
   371         {
   372         {
   372         TheTest.Printf(_L(" %d"), ++failingAllocationNo);
   373         TheTest.Printf(_L(" %d"), ++failingAllocationNo);
   381         if(err != KSqlAtRow)
   382         if(err != KSqlAtRow)
   382             {
   383             {
   383             goto LabelStmtClose;
   384             goto LabelStmtClose;
   384             }
   385             }
   385         
   386         
   386         TPtrC data;
       
   387         err = TheStmt.ColumnText(0, data);
   387         err = TheStmt.ColumnText(0, data);
   388         if(err != KErrNone)
   388         if(err != KErrNone)
   389             {
   389             {
   390             goto LabelStmtClose;
   390             goto LabelStmtClose;
   391             }
   391             }
   451     CreateTestDb(KDbFile);//Creates UTF8 encoded database with one table with one record.
   451     CreateTestDb(KDbFile);//Creates UTF8 encoded database with one table with one record.
   452     
   452     
   453     TInt err = TheDb.Open(KDbFile);
   453     TInt err = TheDb.Open(KDbFile);
   454     TEST2(err, KErrNone);
   454     TEST2(err, KErrNone);
   455     
   455     
       
   456     TBuf<50> data;
       
   457     RSqlColumnReadStream strm;
   456     TInt failingAllocationNo = 0;
   458     TInt failingAllocationNo = 0;
   457     err = KErrNoMemory;
   459     err = KErrNoMemory;
       
   460     TInt len = -1;
   458     while(err == KErrNoMemory)
   461     while(err == KErrNoMemory)
   459         {
   462         {
   460         TheTest.Printf(_L(" %d"), ++failingAllocationNo);
   463         TheTest.Printf(_L(" %d"), ++failingAllocationNo);
   461         OomPreStep(failingAllocationNo);
   464         OomPreStep(failingAllocationNo);
   462         
   465         
   469         if(err != KSqlAtRow)
   472         if(err != KSqlAtRow)
   470             {
   473             {
   471             goto LabelCloseStmt;
   474             goto LabelCloseStmt;
   472             }
   475             }
   473         
   476         
   474         RSqlColumnReadStream strm;
       
   475         err = strm.ColumnText(TheStmt, 0);
   477         err = strm.ColumnText(TheStmt, 0);
   476         if(err != KErrNone)
   478         if(err != KErrNone)
   477             {
   479             {
   478             goto LabelCloseStmt;
   480             goto LabelCloseStmt;
   479             }
   481             }
   480         TBuf<50> data;
       
   481         TRAP(err, strm.ReadL(data, 11));
   482         TRAP(err, strm.ReadL(data, 11));
   482         strm.Close();
   483         strm.Close();
   483         if(err != KErrNone)
   484         if(err != KErrNone)
   484             {
   485             {
   485             goto LabelCloseStmt;
   486             goto LabelCloseStmt;
   502         err = strm.ColumnText(TheStmt, 2);
   503         err = strm.ColumnText(TheStmt, 2);
   503         if(err != KErrNone)
   504         if(err != KErrNone)
   504             {
   505             {
   505             goto LabelCloseStmt;
   506             goto LabelCloseStmt;
   506             }
   507             }
   507         TInt len = -1;
       
   508         TRAP(err, len = strm.Source()->SizeL());//The column value is with 0 length
   508         TRAP(err, len = strm.Source()->SizeL());//The column value is with 0 length
   509         strm.Close();
   509         strm.Close();
   510         if(err != KErrNone)
   510         if(err != KErrNone)
   511             {
   511             {
   512             goto LabelCloseStmt;
   512             goto LabelCloseStmt;
   634     CreateTestDb(KDbFile);//Creates UTF8 encoded database with one table with one record.
   634     CreateTestDb(KDbFile);//Creates UTF8 encoded database with one table with one record.
   635     
   635     
   636     TInt err = TheDb.Open(KDbFile);
   636     TInt err = TheDb.Open(KDbFile);
   637     TEST2(err, KErrNone);
   637     TEST2(err, KErrNone);
   638     
   638     
       
   639     TSqlColumnType colType = ESqlNull;
   639     TInt failingAllocationNo = 0;
   640     TInt failingAllocationNo = 0;
   640     err = KErrNoMemory;
   641     err = KErrNoMemory;
   641     while(err == KErrNoMemory)
   642     while(err == KErrNoMemory)
   642         {
   643         {
   643         TheTest.Printf(_L(" %d"), ++failingAllocationNo);
   644         TheTest.Printf(_L(" %d"), ++failingAllocationNo);
   647         if(err != KErrNone)
   648         if(err != KErrNone)
   648             {
   649             {
   649             goto LabelOomPostStep;
   650             goto LabelOomPostStep;
   650             }
   651             }
   651         
   652         
   652         TSqlColumnType colType = ESqlNull;
       
   653         err = TheStmt.DeclaredColumnType(0, colType);
   653         err = TheStmt.DeclaredColumnType(0, colType);
   654         if(err != KErrNone)
   654         if(err != KErrNone)
   655             {
   655             {
   656             goto LabelStmtClose;
   656             goto LabelStmtClose;
   657             }
   657             }