std.path review: update

Jonathan M Davis jmdavisProg at gmx.com
Sun Jul 17 22:38:43 PDT 2011


On Sunday 17 July 2011 22:08:27 Brian Schott wrote:
> The documentation comments for driveName say that the return value will
> be an empty string in some circumstances, but the code and unit tests
> both say that the behavior is to return null.

The fun part with that is that "" == null and a null string is empty per 
std.array.empty, so it _is_ the empty string. The only difference is that "" 
!is null. So, if the function says that it returns null, then it needs to 
return null. Since it says that it returns the empty string, it could return 
either.

Now, in spite of all that, there's still a problem since the tests verify that 
the return value is null, not empty. Either the documentation should say that 
it returns null, or the tests should be checking for empty, not null. But 
still, the documentation isn't incorrect. Are the tests are perfectly valid, 
but they really shouldn't be testing for is null instead of empty when the 
function is supposed to return empty.

- Jonathan M Davis


More information about the Digitalmars-d mailing list