Martin, I made few changes to this test. The difference file is
attached.
I think it is necessary to modify other find methods and compare method
to force them returning npos instead of the length_error exception
throwing.
What do you think about this?

Thanks,
Anton Pevtsov


-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Thursday, May 04, 2006 04:44
To: [email protected]
Subject: svn commit: r399504 -
/incubator/stdcxx/trunk/tests/strings/21.string.find.cpp


Author: sebor
Date: Wed May  3 17:43:44 2006
New Revision: 399504

URL: http://svn.apache.org/viewcvs?rev=399504&view=rev
Log:
2006-05-03  Martin Sebor  <[EMAIL PROTECTED]>

        * 21.string.find.cpp: Removed tests for length_error, added new
        test cases.

Modified:
   incubator/stdcxx/trunk/tests/strings/21.string.find.cpp

Modified: incubator/stdcxx/trunk/tests/strings/21.string.find.cpp
URL:
http://svn.apache.org/viewcvs/incubator/stdcxx/trunk/tests/strings/21.st
ring.find.cpp?rev=399504&r1=399503&r2=399504&view=diff
========================================================================
======
--- incubator/stdcxx/trunk/tests/strings/21.string.find.cpp (original)
+++ incubator/stdcxx/trunk/tests/strings/21.string.find.cpp Wed May 3 +++ 17:43:44 2006
@@ -22,33 +22,32 @@
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
- * + *

************************************************************************
**/

#include <string>       // for string
-#include <cstdlib>      // for free(), size_t
-#include <stdexcept>    // for length_error
+#include <cstddef>      // size_t
+#include <stdexcept>    // for exception, length_error

#include <21.strings.h> // for StringMembers
#include <driver.h>     // for rw_test()
#include <rw_char.h>    // for rw_widen()


-#define Find(which)    StringMembers::find_ ## which
+/**********************************************************************
+****/
+
+// for convenience and brevity
+
+#define NPOS          _RWSTD_SIZE_MAX
+#define LSTR          StringMembers::long_string
+#define LLEN          StringMembers::long_string_len
+#define Find(which)   StringMembers::find_ ## which

typedef StringMembers::OverloadId OverloadId;
typedef StringMembers::TestCase   TestCase;
typedef StringMembers::Test       Test;
typedef StringMembers::Function   MemFun;

-/**********************************************************************
****/
-
-// for convenience and brevity
-#define NPOS      _RWSTD_SIZE_MAX
-
-#define LSTR      StringMembers::long_string
-#define LLEN      StringMembers::long_string_len
-
static const char* const exceptions[] = {
    "unknown exception", "out_of_range", "length_error",
    "bad_alloc", "exception"
@@ -56,9 +55,10 @@


/***********************************************************************
***/

-// used to exercise +// used to exercise
// find (const value_type*)
-static const TestCase ptr_test_cases [] = {
+static const TestCase
+ptr_test_cases [] = {

#undef TEST
#define TEST(str, arg, res)                                    \
@@ -67,143 +67,159 @@

    //    +----------------------------------- controlled sequence
    //    |             +--------------------- sequence to be found
- // | | +---- expected result - // | | |

- // | | | - // V V V - TEST ("ab", "a", 0), - - TEST ("", "", 0), - TEST ("", "\0", 0), - TEST ("", "a", NPOS), - - TEST ("\0", "", 0), - TEST ("\0", "\0", 0), - TEST ("\0", "a", NPOS), - - TEST ("bbcdefghij", "a", NPOS), - TEST ("abcdefghij", "a", 0), - TEST ("abcdefghij", "f", 5), - TEST ("abcdefghij", "j", 9), - - TEST ("edfcbbhjig", "cba", NPOS), - TEST ("edfcbahjig", "cba", 3), - TEST ("edfcbahcba", "cba", 3), - TEST ("cbacbahjig", "cba", 0), - - TEST ("e\0cb\0\0g", "b\0\0g", 3), - TEST ("e\0cb\0\0g", "ecb", NPOS), - TEST ("\0cb\0\0ge", "\0\0ge", 0), - TEST ("\0cb\0\0ge", "cb\0", 1), - TEST ("e\0cbg\0\0", "bg", 3), - TEST ("e\0cbg\0\0", "cba", NPOS), - - TEST ("bcbedfbjih", "a", NPOS), - TEST ("bcaedfajih", "a", 2), - TEST ("bcedfaajih", "a", 5), - TEST ("bcaaedfaji", "a", 2), - - TEST ("aaaaaaaaaa", "aaaaaaaaaa", 0), - TEST ("aaaaabaaaa", "aaaaaaaaaa", NPOS), - TEST ("aaaabaaaaa", "aaaaa", 5), - TEST ("aaaaaaaaaa", "aaaaaaaaa", 0), - TEST ("aaaaaaaaa", "aaaaaaaaaa", NPOS), - - TEST (LSTR, "", 0), - TEST (LSTR, "a", NPOS), - TEST (LSTR, "x", 0), - TEST (LSTR, "xxx", 0), - TEST (LSTR, "xxa", NPOS), - TEST ("abc", LSTR, NPOS), - TEST ("xxxxxxxxxx", LSTR, NPOS), - - TEST ("abcdefghij", 0, 0), - TEST ("\0cb\0\0ge", 0, 0), - TEST (LSTR, 0, 0), + // | | +---- expected result
+    //    |             |                |
+    //    |             |                |
+    //    V             V                V
+    TEST ("",           "",              0),
+    TEST ("",           "a",          NPOS),
+    TEST ("",           "\0",            0),
+
+    TEST ("ab",         "a",             0),
+
+    TEST ("\0",         "",              0),
+    TEST ("\0",         "\0",            0),
+    TEST ("\0",         "a",          NPOS),
+
+    TEST ("aababcabcd", "",              0),
+    TEST ("aababcabcd", "a",             0),
+    TEST ("aababcabcd", "ab",            1),
+    TEST ("aababcabcd", "abc",           3),
+    TEST ("aababcabcd", "abcd",          6),
+    TEST ("aababcabcd", "abcde",      NPOS),
+
+    TEST ("bbcdefghij", "a",          NPOS),
+    TEST ("abcdefghij", "a",             0),
+    TEST ("abcdefghij", "f",             5),
+    TEST ("abcdefghij", "j",             9),
+
+    TEST ("edfcbbhjig", "cba",        NPOS),
+    TEST ("edfcbahjig", "cba",           3),
+    TEST ("edfcbahcba", "cba",           3),
+    TEST ("cbacbahjig", "cba",           0),
+
+    TEST ("e\0cb\0\0g", "b\0\0g",        3),
+    TEST ("e\0cb\0\0g", "ecb",        NPOS),
+    TEST ("\0cb\0\0ge", "\0\0ge",        0),
+    TEST ("\0cb\0\0ge", "cb\0",          1),
+    TEST ("e\0cbg\0\0", "bg",            3),
+    TEST ("e\0cbg\0\0", "cba",        NPOS),
+
+    TEST ("bcbedfbjih", "a",          NPOS),
+    TEST ("bcaedfajih", "a",             2),
+    TEST ("bcedfaajih", "a",             5),
+    TEST ("bcaaedfaji", "a",             2),
+
+    TEST ("aaaaaaaaaa", "aaaaaaaaaa",    0),
+    TEST ("aaaaabaaaa", "aaaaaaaaaa", NPOS),
+    TEST ("aaaabaaaaa", "aaaaa",         5),
+    TEST ("aaaaaaaaaa", "aaaaaaaaa",     0),
+    TEST ("aaaaaaaaa",  "aaaaaaaaaa", NPOS),
+
+    TEST (LSTR,         "",              0),
+    TEST (LSTR,         "a",          NPOS),
+    TEST (LSTR,         "x",             0),
+    TEST (LSTR,         "xxx",           0),
+    TEST (LSTR,         "xxa",        NPOS),
+    TEST ("abc",        LSTR,         NPOS),
+    TEST ("xxxxxxxxxx", LSTR,         NPOS),
+
+    TEST ("abcdefghij", 0,               0),
+    TEST ("\0cb\0\0ge", 0,               0),
+    TEST (LSTR,         0,               0),

- TEST ("last test", "test", 5) + TEST ("last test", "test", 5)
};


/***********************************************************************
[...]
***/

Index: 21.string.find.cpp
===================================================================
--- 21.string.find.cpp  (revision 399564)
+++ 21.string.find.cpp  (working copy)
@@ -57,8 +57,7 @@
 
 // used to exercise
 // find (const value_type*)
-static const TestCase
-ptr_test_cases [] = {
+static const TestCase ptr_test_cases [] = {
 
 #undef TEST
 #define TEST(str, arg, res)                                    \
@@ -135,8 +134,7 @@
 
 // used to exercise
 // find (const basic_string&)
-static const TestCase
-str_test_cases [] = {
+static const TestCase str_test_cases [] = {
 
 #undef TEST
 #define TEST(str, arg, res)                                    \
@@ -218,8 +216,7 @@
 
 // used to exercise
 // find (const value_type*, size_type)
-static const TestCase
-ptr_size_test_cases [] = {
+static const TestCase ptr_size_test_cases [] = {
 
 #undef TEST
 #define TEST(str, arg, off, res)                                    \
@@ -316,8 +313,7 @@
 
 // used to exercise
 // find (const value_type*, size_type, size_type)
-static const TestCase
-ptr_size_size_test_cases [] = {
+static const TestCase ptr_size_size_test_cases [] = {
 
 #undef TEST
 #define TEST(str, arg, off, size, res) {        \
@@ -444,8 +440,7 @@
 
 // used to exercise
 // find (const basic_string&, size_type)
-static const TestCase
-str_size_test_cases [] = {
+static const TestCase str_size_test_cases [] = {
 
 #undef TEST
 #define TEST(str, arg, off, res)                                    \
@@ -539,8 +534,7 @@
 
 // used to exercise
 // find (value_type)
-static const TestCase
-val_test_cases [] = {
+static const TestCase val_test_cases [] = {
 
 #undef TEST
 #define TEST(str, val, res)                                     \
@@ -663,11 +657,8 @@
 
 #ifndef _RWSTD_NO_EXCEPTIONS
 
-    // is some exception expected ?
+    // no exceptions expected 
     const char* expected = 0;
-    if (1 == cs.bthrow)
-        expected = exceptions [2];
-
     const char* caught = 0;
 
 #else   // if defined (_RWSTD_NO_EXCEPTIONS)
@@ -729,13 +720,6 @@
 
 #ifndef _RWSTD_NO_EXCEPTIONS
 
-    catch (const std::length_error &ex) {
-        caught = exceptions [2];
-        rw_assert (caught == expected, 0, cs.line,
-                   "line %d. %{$FUNCALL} %{?}expected %s,%{:}"
-                   "unexpectedly%{;} caught std::%s(%#s)",
-                   __LINE__, 0 != expected, expected, caught, ex.what ());
-    }
     catch (const std::exception &ex) {
         caught = exceptions [4];
         rw_assert (0, 0, cs.line,

Reply via email to