stdcxx-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Sebor <se...@roguewave.com>
Subject Re: test for 21.string::erase
Date Tue, 14 Mar 2006 16:49:05 GMT
Anton Pevtsov wrote:
> I've added command line options: --no-exceptions, --no-erase,
> --no-erase-iterator, --no-erase-range, --no-erase-pos, and
> no-erase-count.
> The attached file contains the patch for the test.

Looks good! :)

> 
> Here is the ChangeLog:
> 2006-03-14  Anton Pevtsov  <antonp@moscow.vdiweb.com>
> 
>     * 21.string.erase.cpp: (rw_opt_no_exceptions, rw_opt_no_erase, 

No colon between the file name and the opening parenthesis please.

>     rw_opt_no_erase_pos, rw_opt_no_erase_count,
>     rw_opt_no_erase_iterator,     rw_opt_no_erase_range) : New command 
> line options.
>     (test_erase) : Added check for the --no-exceptions option.

No space between the closing paren and the colon.

>     (note_test_disabled) : New function to display the disable note.
>     (run_test) : Changed to support new command line options.
>     (main) : Added new command line options.

Please go ahead and commit it with the changes to the ChangeLog.

Thanks!
Martin

> 
> 
> Thanks,
> Anton Pevtsov
> 
> -----Original Message-----
> From: Martin Sebor [mailto:sebor@roguewave.com] Sent: Sunday, March 12, 
> 2006 04:08
> To: stdcxx-dev@incubator.apache.org
> Subject: Re: test for 21.string::erase
> 
> 
> Anton Pevtsov wrote:
> 
>>> The attached file contains new version of the test for string::erase. 
>>> I merged tests for all erase versions into one function and added 
>>> UserChar's tests.
>>
>>  
>>
> 
> Okay, thanks. I found a few small problems and decided to correct them
> myself and commit the result -- see:
>   http://svn.apache.org/viewcvs?rev=385224&view=rev
> 
> Attached is a diff of the changes. The most important one is to the
> CALLFMT and CALLARGS macros where the test would fail to print the
> string argument past the first NUL. The other (minor) issues were the
> bad spelling of the $Id$ RCS keyword (missing closing $) and the file
> name (should be 21.string.erase). Please look over the diff so that we
> can avoid running into the same issues in the future  :)
> Also, I would like each test to be able to disable exceptions using a
> command line option (say, "--no-exceptions"). Could you please add this
> capability to this test? Finally, it would be good to provide options to
> disable each overload of the tested function, i.e., --no-erase,
> --no-erase-iterator, --no-erase-range, --no-erase-pos, and
> no-erase-count. Let's also use this naming convention in the rest of the
> string and container tests. We should also have a uniform naming
> convention for the options that control the user defined character type
> and user-defined traits (I used --no-UserTraits in 0.char.cpp but I am
> willing to change it to --no-user_traits of you like that better).
> 
> Thanks again.
> Martin
> 
> 
> 
> ------------------------------------------------------------------------
> 
> Index: 21.string.erase.cpp
> ===================================================================
> --- 21.string.erase.cpp	(revision 385808)
> +++ 21.string.erase.cpp	(working copy)
> @@ -243,7 +243,6 @@
>                 CALLARGS, int (sizeof (charT)), pstr, res);
>  }
>  
> -
>  /**************************************************************************/
>  
>  static void
> @@ -294,6 +293,20 @@
>  
>  /**************************************************************************/
>  
> +static int rw_opt_no_char_traits;       // for --no-char_traits
> +static int rw_opt_no_user_traits;       // for --no-user_traits
> +
> +static int rw_opt_no_user_chars;        // for --no-user_chars
> +static int rw_opt_no_exceptions;        // for --no-exceptions
> +
> +static int rw_opt_no_erase;             // for --no-erase
> +static int rw_opt_no_erase_pos;         // for --no-erase-pos
> +static int rw_opt_no_erase_count;       // for --no-erase-count
> +static int rw_opt_no_erase_iterator;    // for --no-erase-iterator
> +static int rw_opt_no_erase_range;       // for --no-erase-range
> +
> +/**************************************************************************/
> +
>  static void
>  test_erase (MemFun *pfid, int which)
>  {
> @@ -385,9 +398,11 @@
>  
>  #ifndef _RWSTD_NO_EXCEPTIONS
>  
> -    TEST ("\0",           2,                   1, "\0",          true);
> -    TEST ("a",            2,                   1, "a",           true);
> -    TEST (long_string,    long_string_len + 1, 1, long_string,   true);
> +    if (! rw_opt_no_exceptions) {
> +        TEST ("\0",           2,                   1, "\0",          true);
> +        TEST ("a",            2,                   1, "a",           true);
> +        TEST (long_string,    long_string_len + 1, 1, long_string,   true);
> +    }
>  
>  #endif   // _RWSTD_NO_EXCEPTIONS
>  
> @@ -423,27 +438,47 @@
>  
>  /**************************************************************************/
>  
> -static int rw_opt_no_char_traits;   // for --no-char_traits
> -static int rw_opt_no_user_traits;   // for --no-user_traits
> -static int rw_opt_no_user_chars;    // for --no-user_chars
> +static void 
> +note_test_disabled (MemFun *pfid, int which)
> +{
> +    rw_note (0, 0, 0, "std::basic_string<%s, %s<%1$s>, %s<%1$s>>::"
> +             "erase (%{?}%{?}size_type pos%{;}%{?}, size_type n%{;}%{;}"
> +             "%{?}iterator first%{?}, iterator last%{;}%{;}) "
> +             "test disabled",
> +             pfid->cname_, pfid->tname_, pfid->aname_, 4 > which, 
> +             2 == which || 3 == which, 3 == which, 4 <= which, which == 5);
> +}
>  
> -/**************************************************************************/
> -
>  static void
>  run_test (MemFun *pfid)
>  {
> -    if (pfid->tname_ && rw_opt_no_user_traits) {
> +    if (MemFun::UserTraits == pfid->tid_ && rw_opt_no_user_traits) {
>          rw_note (1 < rw_opt_no_user_traits++, 0, 0,
> -                 "user defined traits test disabled");
> +                 "user defined traits tests disabled");
>      }
> -    else if (!pfid->tname_ && rw_opt_no_char_traits) {
> +    else if (MemFun::DefaultTraits == pfid->tid_ && rw_opt_no_char_traits)
{
>          rw_note (1 < rw_opt_no_char_traits++, 0, 0,
> -                 "char_traits test disabled");
> +                 "char_traits tests disabled");
>      }
>      else {
> +
> +        if (rw_opt_no_exceptions)
> +            rw_note (1 < rw_opt_no_exceptions++, 0, 0,
> +                     "string::erase exceptions tests disabled");
> +
>          // exercise all erase overloads
> -        for (int i = 1; i <= 5; i++)
> -            test_erase (pfid, i);
> +#undef TEST
> +#define TEST(option, n)                         \
> +        if (option)                             \
> +            note_test_disabled (pfid, n);       \
> +        else                                    \
> +            test_erase (pfid, n);               
> +
> +        TEST (rw_opt_no_erase,          1);
> +        TEST (rw_opt_no_erase_pos,      2);
> +        TEST (rw_opt_no_erase_count,    3);
> +        TEST (rw_opt_no_erase_iterator, 4);
> +        TEST (rw_opt_no_erase_range,    5);
>      }
>  }
>  
> @@ -512,9 +547,21 @@
>                      0 /* no comment */,
>                      run_test,
>                      "|-no-char_traits# "
> -                    "|-no-user_traits# ",
> -                    "|-no-user_chars",
> +                    "|-no-user_traits# "
> +                    "|-no-user_chars# "
> +                    "|-no-exceptions# "
> +                    "|-no-erase# "
> +                    "|-no-erase-pos# "
> +                    "|-no-erase-count# "
> +                    "|-no-erase-iterator# "
> +                    "|-no-erase-range",
>                      &rw_opt_no_char_traits,
>                      &rw_opt_no_user_traits,
> -                    &rw_opt_no_user_chars);
> +                    &rw_opt_no_user_chars,
> +                    &rw_opt_no_exceptions,
> +                    &rw_opt_no_erase,
> +                    &rw_opt_no_erase_pos,
> +                    &rw_opt_no_erase_count,
> +                    &rw_opt_no_erase_iterator,
> +                    &rw_opt_no_erase_range);
>  }


Mime
View raw message