Boost logo

Boost Testing :

From: John Maddock (john_at_[hidden])
Date: 2005-06-02 11:12:48


>> One has to wonder why the test functions in 7.1 then and fails in
>> 8.0. Surely you don't imply that the older libraries were "better".
>
> Well, "old" CRT returned NULL when input was negative. It's documented in
> MSDN and quite obvious when looking at source code. I dunno if returning
> NULL makes them "better" or not; it depends on what you do with result.
> However, if you test the result for NULL, probably you might test time_t
> value instead for negative, before actually calling localtime?

The "new" behaviour doesn't appear to be standard conforming: time_t is an
arithmetic type, and C99 says: "The range and precision of times
representable in clock_t and time_t are implementation-defined", while for
localtime it says: "returns: The localtime function returns a pointer to the
broken-down time, or a null pointer if the specified time cannot be
converted to local time", so the current code appears correct with respect
to the standard. From a practical viewpoint, I guess the question is are
there any platforms that accept negative times? It's not as illogical as it
might appear if they do - it's the only way to represent dates before 1970 I
believe.

Just my 2c worth,

John.


Boost-testing list run by mbergal at meta-comm.com