You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@stdcxx.apache.org by Anton Pevtsov <an...@moscow.vdiweb.com> on 2006/02/10 17:14:33 UTC

test for lib.alg.min.max

The attached file contains the tests for the lib.alg.min.max algorithms
(min, max, min_element, max_element).

With best wishes,
Anton Pevtsov


Re: test for lib.alg.min.max

Posted by Martin Sebor <se...@roguewave.com>.
Anton Pevtsov wrote:
> The attached file contains the tests for the lib.alg.min.max algorithms
> (min, max, min_element, max_element).

Great, thanks! Here's the commit:
http://svn.apache.org/viewcvs.cgi?rev=377556&view=rev

A couple of comments below...

[...]
> template <class T, class Predicate>
> void test_min_max (int              line,
>                    const char       a,
>                    const char       b,
>                    const T*,
>                    const Predicate *ppred,
>                    bool             min)

I renamed min to test_min to avoid colliding with the min macro
that is sometimes (incorrectly) #defined on Windows.

> {
>     _RWSTD_UNUSED(ppred);

This is unnecessary -- ppred is being used.

> 
[...]
>     rw_assert (exp_res == res.val_ && exp_id == res.origin_, 0, line,
>                "line %d %s <%s%{?}, %s%{;}> (%#c, %#c) returned "
>                "value %#c, id %d; expected value %#c, id %d",
>                __LINE__, fname, tname, ppred, funname, a, b,

You need 0 != ppred (or !!ppred) and not just ppred above. ppred is
a pointer but the %{?} directive extracts an int from the argument
list. On 64-bit platforms where pointers are 64-bits wide and ints
are only 32 bits (i.e., all sane platforms), the function would
extract only half the argument leaving the other half for the next
directive.

Martin