44 * Creates the database file and the directory that the test file will be stored. |
44 * Creates the database file and the directory that the test file will be stored. |
45 */ |
45 */ |
46 static void CreateTestEnv() |
46 static void CreateTestEnv() |
47 { |
47 { |
48 TInt err = TheFs.Connect(); |
48 TInt err = TheFs.Connect(); |
49 TheTest(err == KErrNone); |
49 TestTestLine(err == KErrNone, __LINE__); |
50 |
50 |
51 err = TheFs.ShareAuto(); |
51 err = TheFs.ShareAuto(); |
52 TheTest(err == KErrNone); |
52 TestTestLine(err == KErrNone,__LINE__); |
53 |
53 |
54 TFileName testDir; |
54 TFileName testDir; |
55 testDir.Copy(TPtrC8((const TUint8*)KTestDir)); |
55 testDir.Copy(TPtrC8((const TUint8*)KTestDir)); |
56 err = TheFs.MkDir(testDir); |
56 err = TheFs.MkDir(testDir); |
57 TheTest(err == KErrNone || err == KErrAlreadyExists); |
57 TestTestLine(err == KErrNone || err == KErrAlreadyExists, __LINE__); |
58 |
58 |
59 TFileName fname; |
59 TFileName fname; |
60 fname.Copy(TPtrC8((const TUint8*)KTestDb)); |
60 fname.Copy(TPtrC8((const TUint8*)KTestDb)); |
61 (void)TheFs.Delete(fname); |
61 (void)TheFs.Delete(fname); |
62 } |
62 } |
108 { |
108 { |
109 if(!aValue) |
109 if(!aValue) |
110 { |
110 { |
111 PrintErrMsg(); |
111 PrintErrMsg(); |
112 DestroyTestEnv(); |
112 DestroyTestEnv(); |
113 TheTest(EFalse, aLine); |
113 TestTestLine(EFalse, aLine); |
114 } |
114 } |
115 } |
115 } |
116 static void Check(TInt aValue, TInt aExpected, TInt aLine) |
116 static void Check(TInt aValue, TInt aExpected, TInt aLine) |
117 { |
117 { |
118 if(aValue != aExpected) |
118 if(aValue != aExpected) |
119 { |
119 { |
120 PrintErrMsg(); |
120 PrintErrMsg(); |
121 DestroyTestEnv(); |
121 DestroyTestEnv(); |
122 RDebug::Print(_L("*** Expected error: %d, got: %d\r\n"), aExpected, aValue); |
122 RDebug::Print(_L("*** Expected error: %d, got: %d\r\n"), aExpected, aValue); |
123 TheTest(EFalse, aLine); |
123 TestTestLine(EFalse, aLine); |
124 } |
124 } |
125 } |
125 } |
126 #define TEST(arg) ::Check((arg), __LINE__) |
126 #define TEST(arg) ::Check((arg), __LINE__) |
127 #define TEST2(aValue, aExpected) ::Check(aValue, aExpected, __LINE__) |
127 #define TEST2(aValue, aExpected) ::Check(aValue, aExpected, __LINE__) |
128 |
128 |
418 sqlite3_close(TheDb); |
418 sqlite3_close(TheDb); |
419 TheDb = NULL; |
419 TheDb = NULL; |
420 DeleteFile(KTestDb); |
420 DeleteFile(KTestDb); |
421 |
421 |
422 dtstr1.Format(_L("%04d-%02d-%02d,%02d:%02d:%02d"), dt.Year(), dt.Month() + 1, dt.Day() + 1, dt.Hour(), dt.Minute(), dt.Second()); |
422 dtstr1.Format(_L("%04d-%02d-%02d,%02d:%02d:%02d"), dt.Year(), dt.Month() + 1, dt.Day() + 1, dt.Hour(), dt.Minute(), dt.Second()); |
423 TheTest.Printf(_L("Universal date&time=\"%S\"\n"), &dtstr1); |
423 |
424 TheTest.Printf(_L("SQLite date&time=\"%S\"\n"), &dtstr2); |
424 // For the C-Style printout |
|
425 _LIT8(KUniversalTimeText,"Universal date&time="); |
|
426 _LIT8(KSQLiteTimeText, "SQLite date&time="); |
|
427 TBuf8<96> dtstr1print; |
|
428 TBuf8<96> dtstr2print; |
|
429 dtstr1print.Copy(dtstr1); |
|
430 dtstr2print.Copy(dtstr2); |
|
431 dtstr1print.Insert(0,KUniversalTimeText); |
|
432 dtstr2print.Insert(0,KSQLiteTimeText); |
|
433 TestPrintf((const char*)(dtstr1print.PtrZ())); |
|
434 TestPrintf((const char*)(dtstr2print.PtrZ())); |
425 |
435 |
426 //Comapare and fail if dates are not equal (+- 1 second) |
436 //Comapare and fail if dates are not equal (+- 1 second) |
427 TLex lex; |
437 TLex lex; |
428 lex = dtstr2.Mid(0, 4); |
438 lex = dtstr2.Mid(0, 4); |
429 TInt sqlyear; |
439 TInt sqlyear; |
463 TEST(diff.Int() <= 1); |
473 TEST(diff.Int() <= 1); |
464 } |
474 } |
465 |
475 |
466 void DoTest() |
476 void DoTest() |
467 { |
477 { |
468 TheTest.Start(_L("@SYMTestCaseID:PDS-SQLITE3-UT-4029: SQLite file handle test")); |
478 TestStart("@SYMTestCaseID:PDS-SQLITE3-UT-4029: SQLite file handle test"); |
469 FileHandleTest(); |
479 FileHandleTest(); |
470 |
480 |
471 TheTest.Next(_L("@SYMTestCaseID:PDS-SQLITE3-CT-4028: DEF121506 test")); |
481 TestNext("@SYMTestCaseID:PDS-SQLITE3-CT-4028: DEF121506 test"); |
472 DEF121506(); |
482 DEF121506(); |
473 |
483 |
474 TheTest.Next(_L("@SYMTestCaseID:PDS-SQLITE3-CT-4046: DEF140020 test")); |
484 TestNext("@SYMTestCaseID:PDS-SQLITE3-CT-4046: DEF140020 test"); |
475 DEF140020(); |
485 DEF140020(); |
476 |
486 |
477 TheTest.Next(_L("@SYMTestCaseID:PDS-SQLITE3-CT-4047: SQLITE, \"CREATE INDEX\" sql crashes the SQLite library")); |
487 TestNext("@SYMTestCaseID:PDS-SQLITE3-CT-4047: SQLITE, \"CREATE INDEX\" sql crashes the SQLite library"); |
478 DEF143066(); |
488 DEF143066(); |
479 |
489 |
480 TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-SQL-CT-4048 DEF143151: SQLite, strftime() returns incorrect result")); |
490 TestNext(" @SYMTestCaseID:SYSLIB-SQL-CT-4048 DEF143151: SQLite, strftime() returns incorrect result"); |
481 DEF143151(); |
491 DEF143151(); |
482 } |
492 } |
483 |
493 |
484 /////////////////////////////////////////////////////////////////////////////////////// |
494 /////////////////////////////////////////////////////////////////////////////////////// |
485 |
495 |
486 TInt E32Main() |
496 TInt E32Main() |
487 { |
497 { |
488 TheTest.Title(); |
498 TestOpen(KTestName); |
|
499 TestTitle(); |
489 CTrapCleanup* tc = CTrapCleanup::New(); |
500 CTrapCleanup* tc = CTrapCleanup::New(); |
490 |
501 |
491 __UHEAP_MARK; |
502 __UHEAP_MARK; |
492 |
503 |
493 CreateTestEnv(); |
504 CreateTestEnv(); |
494 DoTest(); |
505 DoTest(); |
495 DestroyTestEnv(); |
506 DestroyTestEnv(); |
496 |
507 |
497 __UHEAP_MARKEND; |
508 __UHEAP_MARKEND; |
498 |
509 |
499 TheTest.End(); |
510 TestEnd(); |
500 TheTest.Close(); |
511 TestClose(); |
501 delete tc; |
512 delete tc; |
502 User::Heap().Check(); |
513 User::Heap().Check(); |
503 return KErrNone; |
514 return KErrNone; |
504 } |
515 } |