diff options
| author | joost <joost@3ad0048d-3df7-0310-abae-a5850022a9f2> | 2011-02-24 22:15:46 +0000 |
|---|---|---|
| committer | joost <joost@3ad0048d-3df7-0310-abae-a5850022a9f2> | 2011-02-24 22:15:46 +0000 |
| commit | c3933f8d9609f9b0f69c66f776390d094351be08 (patch) | |
| tree | a26f6ed3faea2a5e197268b95c942500944775af /packages/fcl-db | |
| parent | b0221408da225fe6d102fe242d12ebea77b6f786 (diff) | |
| download | fpc-c3933f8d9609f9b0f69c66f776390d094351be08.tar.gz | |
* Added test for ftTime fields
* Fixed problem with ftTime field values that exceed 24 hours (odbc)
git-svn-id: http://svn.freepascal.org/svn/fpc/trunk@17000 3ad0048d-3df7-0310-abae-a5850022a9f2
Diffstat (limited to 'packages/fcl-db')
| -rw-r--r-- | packages/fcl-db/tests/sqldbtoolsunit.pas | 2 | ||||
| -rw-r--r-- | packages/fcl-db/tests/testdbbasics.pas | 26 | ||||
| -rw-r--r-- | packages/fcl-db/tests/toolsunit.pas | 30 |
3 files changed, 57 insertions, 1 deletions
diff --git a/packages/fcl-db/tests/sqldbtoolsunit.pas b/packages/fcl-db/tests/sqldbtoolsunit.pas index 3e18104c27..0c4482fbd2 100644 --- a/packages/fcl-db/tests/sqldbtoolsunit.pas +++ b/packages/fcl-db/tests/sqldbtoolsunit.pas @@ -27,7 +27,7 @@ const MySQLdbTypes = [mysql40,mysql41,mysql50]; '', 'DECIMAL(18,4)', 'DATE', - 'TIMESTAMP', + 'TIME', 'TIMESTAMP', '', '', diff --git a/packages/fcl-db/tests/testdbbasics.pas b/packages/fcl-db/tests/testdbbasics.pas index 35fb9ff8d7..1874fd5545 100644 --- a/packages/fcl-db/tests/testdbbasics.pas +++ b/packages/fcl-db/tests/testdbbasics.pas @@ -54,6 +54,7 @@ type procedure TestSupportFloatFields; procedure TestSupportLargeIntFields; procedure TestSupportDateFields; + procedure TestSupportTimeFields; procedure TestSupportCurrencyFields; procedure TestSupportBCDFields; procedure TestSupportfmtBCDFields; @@ -1917,6 +1918,31 @@ begin ds.close; end; +procedure TTestDBBasics.TestSupportTimeFields; +var i : byte; + ds : TDataset; + Fld : TField; + s : string; + millisecond: word; + second : word; + minute : word; + hour : word; +begin + TestfieldDefinition(ftTime,8,ds,Fld); + + for i := 0 to testValuesCount-1 do + begin + // Format the datetime in the format hh:nn:ss:zzz, where the hours can be bigger then 23. + DecodeTime(fld.AsDateTime,hour,minute,second,millisecond); + hour := hour + (trunc(Fld.AsDateTime) * 24); + s := Format('%.2d',[hour]) + ':' + format('%.2d',[minute]) + ':' + format('%.2d',[second]) + ':' + format('%.3d',[millisecond]); + + AssertEquals(testTimeValues[i],s); + ds.Next; + end; + ds.close; +end; + procedure TTestDBBasics.TestSupportCurrencyFields; var i : byte; diff --git a/packages/fcl-db/tests/toolsunit.pas b/packages/fcl-db/tests/toolsunit.pas index 4ef3b38049..8ad6a59ebd 100644 --- a/packages/fcl-db/tests/toolsunit.pas +++ b/packages/fcl-db/tests/toolsunit.pas @@ -157,6 +157,35 @@ const '1900-01-01' ); + testTimeValues : Array[0..testValuesCount-1] of string = ( + '10:45:12:000', + '00:00:00:000', + '24:00:00:000', + '33:25:15:000', + '04:59:16:000', + '05:45:59:000', + '16:35:42:000', + '14:45:52:000', + '12:45:12:000', + '18:45:22:000', + '19:45:12:000', + '14:45:14:000', + '16:45:12:000', + '11:45:12:000', + '15:35:12:000', + '16:45:12:000', + '13:55:12:000', + '13:46:12:000', + '15:35:12:000', + '17:25:12:000', + '19:45:12:000', + '10:54:12:000', + '12:25:12:000', + '20:15:12:000', + '12:25:12:000' + ); + + var dbtype, dbconnectorname, dbconnectorparams, @@ -256,6 +285,7 @@ begin if DBConnectorRefCount>0 then exit; testValues[ftString] := testStringValues; testValues[ftFixedChar] := testStringValues; + testValues[ftTime] := testTimeValues; testValues[ftFMTBcd] := testFmtBCDValues; for i := 0 to testValuesCount-1 do begin |
