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/26 17:12:24 UTC

test for lib.partial.sum

The attached file contains the test for the lib.partial.sum algorithm. 

With best wishes,
Anton Pevtsov


Re: test for lib.partial.sum

Posted by Martin Sebor <se...@roguewave.com>.
Martin Sebor wrote:
> Anton Pevtsov wrote:
[...]
>>         rw_assert (success, 0, __LINE__,
>>                    "step %zu: partial_sum <%s, %s%{?}, %s%{;}> = %p"
>>                    " expected %p, difference %td",
>>                    i + 1, itname, outname, binop, opname, res, dst_end,
>>                    res - dst_end);
> 
> 
> I think I now understand your suggestion for an %{Y=*.*} directive
> analogous to %{X=*.*}. I think we can simply extend class X and
> define operator+=() et al to avoid having to even define Y. Once
> we've done than we need to remember to revisit these tests and
> 1) remove class Y and b) add enhance the diagnostic output to
> print out the sequences of objects of type X as we do elsewhere.

I just did both with the changes below. Check them out and let me
know if you find anything wrong or if you can think of improvements.

   http://svn.apache.org/viewcvs?rev=381513&view=rev
   http://svn.apache.org/viewcvs?rev=381511&view=rev

Martin

Re: test for lib.partial.sum

Posted by Martin Sebor <se...@roguewave.com>.
Anton Pevtsov wrote:
> The attached file contains the test for the lib.partial.sum algorithm.

Thank you. Committed thus:
http://svn.apache.org/viewcvs?rev=381457&view=rev

[...]
> struct Y: public X
> {
[...]
>     Y (): X () { /* empty */ }
> 
>     Y (const Y &rhs): X (rhs) { /* empty */ }

The default and copy ctor are unnecessary here (the compiler-generated
versions are just as good). I removed them before committing the test.

> };
> 
> /* static */ size_t  Y::n_total_op_plus_;
                ^^^^^^

Careful about qualifying names with the std:: prefix. To detect these
errors compile with the EDG eccp demo. I corrected this in the final
version.

[...]

> template <class InputIterator, class OutputIterator>
> struct PartialSum : PartialSumBase
> {
[...]
>     virtual ~PartialSum() {}

Overriding the dtor here is unnecessary. I removed it.

[...]
> // exercises partial_sum (26.4.3)
> void test_partial_sum (const std::size_t       N,
>                        const PartialSumBase   &alg,
>                        bool                    binop,
>                        bool                    same_seq)
> {
[...]
>         rw_assert (success, 0, __LINE__,
>                    "step %zu: partial_sum <%s, %s%{?}, %s%{;}> = %p"
>                    " expected %p, difference %td",
>                    i + 1, itname, outname, binop, opname, res, dst_end,
>                    res - dst_end);

I think I now understand your suggestion for an %{Y=*.*} directive
analogous to %{X=*.*}. I think we can simply extend class X and
define operator+=() et al to avoid having to even define Y. Once
we've done than we need to remember to revisit these tests and
1) remove class Y and b) add enhance the diagnostic output to
print out the sequences of objects of type X as we do elsewhere.

Martin