stdcxx-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Sebor <>
Subject Re: test for
Date Wed, 18 Jan 2006 02:29:56 GMT
Anton Pevtsov wrote:
> The attached file contains the updated version of the
> test.
> Martin Sebor wrote:
>>> Could you please open an issue in Jira for this one as well, just for 
>>> the record? (Remember to link it to the two above). I'll commit your 
>>> patch once we have an issue to reference.
> I created new issue:
> and link it to STDCXX-83 and STDCXX-84.


> Martin Sebor wrote:
>>> Lastly, would it be possible to test both algorithms (std::search() as
>>> well as std::search_n()) in the same function instead of duplicating 
>>> most of the code in two places?
> I think it will be not easy: these algorithms have different set of the
> input arguments and their tests require different checks.

Okay, let me commit this version for now. If I'm motivated enough
I'll see if I can merge the two into one.

Here it is (with a fixes for the problems noted below):

 > #include <algorithm>    // for rotate, rotate_copy
You meant search and search_n.

 > #include <cstring>      // for strlen
 > #include <cstddef>      // for size_t

There's no need to #include <cstddef> for size_t, it's defined
in <cstring>.

> // exercises std::search()
> template 
> <class ForwardIterator1, class ForwardIterator2, class T, class PredTag>
> void test_search (int line, 
>                   const char *seq1, const char *seq2, 
>                   std::size_t off, 
>                   ForwardIterator1 it1, ForwardIterator2 it2,
>                   const T* , PredTag pred_tag)
> {
>     // 25.1.9, p2:
>     // check the returned iterator
>     rw_assert (result.cur_ == expected.cur_, 0, line, 
>                "std::%s<%s, %s%{?}, %s%{;}> (\"%s\", ..., \"%s\") "
>                "found subsequence at %td, expected at %d",
>                fname, it1name, it2name, pred_tag.pred_inx, predname,
>                seq1, seq2, result.cur_ - first1.cur_, 
>                _RWSTD_SIZE_MAX == off, off);

Note that the type of off is size_t -- the correct formatting
specifier is %zu. This makes no difference on IA32 but on LP64
where the sizes of int and size_t are different the %d directive
extracts only sizeof(int) from the argument list while the function
passes in sizeof(size_t).

(Actually, I suspect the argument list doesn't match the formatting
string in other ways, too).


View raw message