[fpc-devel] Definition of the time-fration in a TDateTime before 30/12/1899

Graeme Geldenhuys graemeg.lists at gmail.com
Mon May 22 16:18:45 CEST 2006


On 5/22/06, Florian Klaempfl <florian at freepascal.org> wrote:
> > Should we convert existing tests to fpcunit ?
>
> No, too much work, no real gain :)

Just curious...

I have never looked at the tests created in FPC, but how much work
(lines of code)  would it take to test something like the following
snippet of our tests we have. (very simple example)  If it isn't to
much work, the benefits will be huge as fpcUnit has a lot of
advantages. TestDecorator, Exception testing, XML output, etc...  As I
said, we use fpcUnit extensively.  Currently running at around 1500+
unit tests, testing database connections, string utils, threading,
etc...

In the example below tiUtils.tiDateTimeAsIntlDateDisp outputs dates in
the ISO international datetime format.  Most of our test are as easy
as this, 1 or 2 liners.  Not to mention fpcUnit give you results in
XML output which we convert to a html page via xslt to be viewer over
the web to see what the nightly build did.

procedure TTestTIUtils.tiDateTimeAsIntlDateDisp;
var
  dt: TDateTime;
begin
  dt := EncodeDate(2006, 1, 18) + EncodeTime(15, 19, 22, 0);
  CheckEquals('2006-01-18 15:19:22',
tiUtils.tiDateTimeAsIntlDateDisp(dt), 'Failed on 1');

  dt := EncodeDate(2002, 1, 02) + EncodeTime(12, 34, 56, 12);
  CheckEquals('2002-01-02 12:34:56',
tiUtils.tiDateTimeAsIntlDateDisp(dt), 'Failed on 2');

  dt := EncodeDate(2006, 1, 18);
  CheckEquals('2006-01-18 00:00:00',
tiUtils.tiDateTimeAsIntlDateDisp(dt), 'Failed on 3');

  dt := EncodeTime(9, 10, 41, 22);
  CheckEquals('0000-00-00 09:10:41',
tiUtils.tiDateTimeAsIntlDateDisp(dt), 'Failed on 4');

  dt := EncodeDateTime(1652, 6, 15, 12, 34, 56, 12);
  CheckEquals('1652-06-15 12:34:56',
tiUtils.tiDateTimeAsIntlDateDisp(dt), 'Failed on 5');

[....]
end;



Regards,
  - Graeme -


-- 
There's no place like 127.0.0.1


More information about the fpc-devel mailing list