random k-sample of a file
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Fri Oct 10 05:32:39 PDT 2008
Christopher Wright wrote:
> Andrei Alexandrescu wrote:
>> enforce(k > 0, "Must pass a strictly positive selection size");
>
> Out of curiosity, why are you using enforce rather than assert?
Enforce is never ignored, even in production builds. You wouldn't want a
release build of your app to skip checking command line arguments.
> I've written an assertions framework, but it provides some more options
> than assert:
>
> expect.because ("Must pass a strictly positive selection size").that
> (k).greaterThan (0);
>
> If that failed, it would produce:
> AssertionException: Expected: greater than 0 but was: -4 -- Must pass a
> strictly positive selection size
That looks pretty darn nice.
Andrei
More information about the Digitalmars-d
mailing list