stdcxx-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From se...@apache.org
Subject svn commit: r395448 - in /incubator/stdcxx/trunk/tests: include/21.strings.h src/21.strings.cpp
Date Thu, 20 Apr 2006 00:20:48 GMT
Author: sebor
Date: Wed Apr 19 17:20:46 2006
New Revision: 395448

URL: http://svn.apache.org/viewcvs?rev=395448&view=rev
Log:
2006-04-19  Martin Sebor  <sebor@roguewave.com>

	* 21_strings.h: New header containing definitions of helpers
	used in clause 21 tests.
	* 21_strings.cpp: New implementation file of the same.

Added:
    incubator/stdcxx/trunk/tests/include/21.strings.h   (with props)
    incubator/stdcxx/trunk/tests/src/21.strings.cpp   (with props)

Added: incubator/stdcxx/trunk/tests/include/21.strings.h
URL: http://svn.apache.org/viewcvs/incubator/stdcxx/trunk/tests/include/21.strings.h?rev=395448&view=auto
==============================================================================
--- incubator/stdcxx/trunk/tests/include/21.strings.h (added)
+++ incubator/stdcxx/trunk/tests/include/21.strings.h Wed Apr 19 17:20:46 2006
@@ -0,0 +1,190 @@
+/************************************************************************
+ *
+ * 21_strings.h - definitions of helpers used in clause 21 tests
+ *
+ * $Id$
+ *
+ ***************************************************************************
+ *
+ * Copyright 2006 The Apache Software Foundation or its licensors,
+ * as applicable.
+ *
+ * Copyright 2006 Rogue Wave Software.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * 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.
+ * 
+ **************************************************************************/
+
+#ifndef RW_21_STRINGS_H_INCLUDED
+#define RW_21_STRINGS_H_INCLUDED
+
+#include <testdefs.h>
+
+/**************************************************************************/
+
+struct _TEST_EXPORT StringMembers {
+
+    // identifiers for the charT template argument
+    enum charT  { Char, WChar, UChar };
+
+    // identifiers for  the Traits template argument
+    enum Traits { DefaultTraits, UserTraits };
+
+    // identifiers for  the Allocator template argument
+    enum Allocator { DefaultAllocator, UserAllocator };
+
+    // identifiers for all overloads of each member function
+    enum MemberFunction {
+
+        //////////////////////////////////////////////////////////////
+        append,
+        append_first = append,
+        // append (const value_type*)
+        append_ptr = append_first,
+        // append (const basic_string&)
+        append_str,
+        // append (const value_type*, size_type)
+        append_ptr_size,
+        // append (const basic_string&, size_type, size_type)
+        append_str_off_size,
+        // append (size_type, value_type)
+        append_size_val,
+        // append (InputIterator, InputIterator)
+        append_range,
+        append_last = append_range,
+
+        // number of member function overloads
+        append_overloads = append_last - append_first,
+
+        //////////////////////////////////////////////////////////////
+        assign,
+        assign_first = assign,
+        // assign (const value_type*)
+        assign_ptr = assign_first,
+        // assign (const basic_string&)
+        assign_str,
+        // assign (const value_type*, size_type)
+        assign_ptr_size,
+        // assign (const basic_string&, size_type, size_type)
+        assign_str_off_size,
+        // assign (size_type, value_type)
+        assign_size_val,
+        // assign (InputIterator, InputIterator)
+        assign_range,
+        assign_last = assign_range,
+
+        // number of member function overloads
+        assign_overloads = assign_last - assign_first,
+
+        //////////////////////////////////////////////////////////////
+        insert,
+        insert_first = insert,
+        // insert (size_type, const value_type*)
+        insert_off_ptr = insert_first,
+        // insert (size_type, const basic_string&)
+        insert_off_str,
+        // insert (size_type, const value_type*, size_type)
+        insert_off_ptr_size,
+        // insert (size_type, basic_string&, size_type, size_type)
+        insert_off_str_off_size,
+        // insert (size_type, size_type, value_type)
+        insert_off_size_val,
+        // insert (iterator, value_type)
+        insert_val,
+        // insert (iterator, size_type, value_type)
+        insert_size_val,
+        // insert (iterator p, InputIterator, InputIterator)
+        insert_range,
+        insert_last = insert_range,
+
+        // number of member function overloads
+        insert_overloads = insert_last - insert_first,
+
+        //////////////////////////////////////////////////////////////
+        replace,
+        replace_first = replace,
+        // (size_type, size_type, const value_type*)
+        replace_off_size_ptr = replace_first,
+        // (size_type, size_type, basic_string&)
+        replace_off_size_str,
+        // (size_type1, size_type, const value_type*, size_type)
+        replace_off_size_ptr_size,
+        // (size_type, size_type, const basic_string&, size_type, size_type)
+        replace_off_size_str_off_size,
+        // (size_type, size_type, size_type, value_type)
+        replace_off_size_size_val,
+        // (iterator, iterator, const value_type*)
+        replace_ptr,
+        // (iterator, iterator, const basic_string&)
+        replace_str,
+        // (iterator, iterator, const value_type*, size_type)
+        replace_ptr_size,
+        // (iterator, iterator, size_type, value_type)
+        replace_size_val,
+        // (iterator, iterator, InputIterator, InputIterator)
+        replace_range,
+        replace_last = replace_range,
+
+        // number of member function overloads
+        replace_overloads = replace_last - replace_first,
+
+        //////////////////////////////////////////////////////////////
+        // must be last: total number of member functions
+        member_functions
+    };
+
+    // describes a single test case for any overload
+    // of any member function
+    struct TestCase {
+        int           line;      // test case line number
+
+        int           off;       // offset (position argument)
+        int           size;      // size (count argument)
+        int           val;       // value (single character to append)
+
+        const char*   str;       // controlled sequence
+        _RWSTD_SIZE_T str_len;   // length of sequence
+
+        const char*   arg;       // sequence to insert
+        _RWSTD_SIZE_T arg_len;   // length of sequence
+
+        const char*   res;       // resulting sequence
+        _RWSTD_SIZE_T res_len;   // length of sequence
+
+        int           bthrow;    // exception expected
+    };
+
+    // describes a set of test cases for a single overload
+    // of a member function
+    struct Test {
+        MemberFunction   which;        // which overload of assign()
+        const TestCase  *cases;        // test cases to exercise
+        _RWSTD_SIZE_T    case_count;   // number of test cases
+        const char      *funsig;       // function signature
+    };
+
+    // dynamically allocates and formats a string describing
+    // the call to the member function, including the values
+    // of its arguments, specfified by its arguments
+    static char*
+    format (charT, Traits, Allocator, MemberFunction, const TestCase&);
+
+    // array of integers to use for command line option
+    // processing (to disable individual overloads of all
+    // member functions)
+    static int
+    opt_memfun_disabled [member_functions];
+};
+
+
+#endif   // RW_21_STRINGS_H_INCLUDED

Propchange: incubator/stdcxx/trunk/tests/include/21.strings.h
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/stdcxx/trunk/tests/include/21.strings.h
------------------------------------------------------------------------------
    svn:keywords = Id

Added: incubator/stdcxx/trunk/tests/src/21.strings.cpp
URL: http://svn.apache.org/viewcvs/incubator/stdcxx/trunk/tests/src/21.strings.cpp?rev=395448&view=auto
==============================================================================
--- incubator/stdcxx/trunk/tests/src/21.strings.cpp (added)
+++ incubator/stdcxx/trunk/tests/src/21.strings.cpp Wed Apr 19 17:20:46 2006
@@ -0,0 +1,139 @@
+/************************************************************************
+ *
+ * 21.strings.cpp - definitions of helpers used in clause 21 tests
+ *
+ * $Id$
+ *
+ ***************************************************************************
+ *
+ * Copyright 2006 The Apache Software Foundation or its licensors,
+ * as applicable.
+ *
+ * Copyright 2006 Rogue Wave Software.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * 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 <21.strings.h>
+#include <rw_printf.h>
+
+#include <stddef.h>
+
+
+static const char* const char_names[] = {
+    "char", "wchar_t", "UserChar"
+};
+
+static const char* const traits_names[] = {
+    "char_traits", "UserTraits"
+};
+
+static const char* const allocator_names[] = {
+    "allocator", "UserAllocator"
+};
+
+static const char* const function_names[] = {
+    "append", "assign", "erase", "insert", "replace"
+};
+
+
+int StringMembers::
+opt_memfun_disabled [StringMembers::member_functions];
+
+
+char* StringMembers::
+format (charT cid, Traits tid, Allocator aid, MemberFunction which,
+        const TestCase &tcase)
+{
+    char*  buf     = 0;
+    size_t bufsize = 0;
+
+    const bool self = 0 == tcase.arg;
+
+    if (   DefaultTraits == tid
+        && (Char == cid || WChar == cid))
+        rw_asnprintf (&buf, &bufsize,
+                      "std::%{?}w%{;}string (%{?}%{#*s}%{;}).",
+                      WChar == cid,
+                      tcase.str != 0, int (tcase.str_len), tcase.str);
+    else
+        rw_asnprintf (&buf, &bufsize,
+                      "std::basic_string<%s, %s<%1$s>, %s<%1$s>>"
+                      "(%{?}%{#*s}%{;}).",
+                      char_names [cid],
+                      traits_names [tid],
+                      allocator_names [aid],
+                      tcase.str != 0, int (tcase.str_len), tcase.str);
+
+    const char *fname = "assign";
+
+    switch (which) {
+    case append_ptr:
+        fname = "append";
+    case assign_ptr:
+        rw_asnprintf (&buf, &bufsize,
+                      "%{+}%s (%{?}%{#*s}%{;}%{?}this->c_str ()%{;})",
+                      fname, !self, int (tcase.arg_len), tcase.arg, self);
+        break;
+
+    case append_str:
+        fname = "append";
+    case assign_str:
+        rw_asnprintf (&buf, &bufsize,
+                      "%{+}%s (%{?}string (%{#*s})%{;}%{?}*this%{;})",
+                      fname, !self, int (tcase.arg_len), tcase.arg, self);
+        break;
+
+    case append_ptr_size:
+        fname = "append";
+    case assign_ptr_size:
+        rw_asnprintf (&buf, &bufsize, "%{+}%s ("
+                      "%{?}%{#*s}%{;}%{?}this->c_str ()%{;}, %zu)",
+                      fname, !self, int (tcase.arg_len), tcase.arg,
+                      self, tcase.size);
+        break;
+
+    case append_str_off_size:
+        fname = "append";
+    case assign_str_off_size:
+        rw_asnprintf (&buf, &bufsize, "%{+}%s ("
+                      "%{?}string (%{#*s})%{;}%{?}*this%{;}, %zu, %zu)",
+                      fname, !self, int (tcase.arg_len), tcase.arg, self,
+                      tcase.off, tcase.size);
+        break;
+
+    case append_size_val:
+        fname = "append";
+    case assign_size_val:
+        rw_asnprintf (&buf, &bufsize,
+                      "%{+} %s (%zu, %#c)", tcase.size, tcase.val);
+        break;
+
+    case append_range:
+        fname = "append";
+    case assign_range:
+        rw_asnprintf (&buf, &bufsize, "%{+}%s ("
+                      "%{?}%{#*s}%{;}%{?}*this%{;}.begin + %zu, "
+                      "%{?}%{#*s}%{;}%{?}*this%{;}.begin + %zu)",
+                      fname, !self, int (tcase.arg_len), tcase.arg,
+                      self, tcase.off, !self, int (tcase.arg_len), tcase.arg,
+                      self, tcase.off + tcase.size);
+        break;
+
+    default:
+        RW_ASSERT (!"test logic error: unknown overload");
+    }
+
+    return buf;
+}

Propchange: incubator/stdcxx/trunk/tests/src/21.strings.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/stdcxx/trunk/tests/src/21.strings.cpp
------------------------------------------------------------------------------
    svn:keywords = Id



Mime
View raw message