From stdcxx-dev-return-1208-apmail-incubator-stdcxx-dev-archive=incubator.apache.org@incubator.apache.org Thu Apr 20 15:06:10 2006 Return-Path: Delivered-To: apmail-incubator-stdcxx-dev-archive@www.apache.org Received: (qmail 64852 invoked from network); 20 Apr 2006 15:05:46 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 20 Apr 2006 15:05:46 -0000 Received: (qmail 6139 invoked by uid 500); 20 Apr 2006 15:05:45 -0000 Delivered-To: apmail-incubator-stdcxx-dev-archive@incubator.apache.org Received: (qmail 6117 invoked by uid 500); 20 Apr 2006 15:05:45 -0000 Mailing-List: contact stdcxx-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: stdcxx-dev@incubator.apache.org Delivered-To: mailing list stdcxx-dev@incubator.apache.org Received: (qmail 6106 invoked by uid 99); 20 Apr 2006 15:05:45 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 20 Apr 2006 08:05:45 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: domain of AntonP@moscow.vdiweb.com designates 195.210.189.132 as permitted sender) Received: from [195.210.189.132] (HELO mail.moscow.vdiweb.com) (195.210.189.132) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 20 Apr 2006 08:05:43 -0700 X-MimeOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: quoted-printable Subject: RE: svn commit: r395448 - in /incubator/stdcxx/trunk/tests: include/21.strings.h src/21.strings.cpp Date: Thu, 20 Apr 2006 19:05:47 +0400 Message-ID: <4D6A8407B7AC6F4D95B0E55C4E7C4C620412EC20@exmsk.moscow.vdiweb.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: svn commit: r395448 - in /incubator/stdcxx/trunk/tests: include/21.strings.h src/21.strings.cpp Thread-Index: AcZkEGzCFQObuYDHQKuyK8ojcS0SDQAciaUg From: "Anton Pevtsov" To: X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Martin, it is a great idea to move all "common places" from strings tests to the test driver. I think it is possible to have only main and method-specific test functions (i.e. code with method calls), and test cases arrays declaration in each test. Now I've implemented tests for find methods, substr, operator +=3D and compare (they are not on svn, but they are ready).=20 I'll modify them using the 21.strings header, ok? And I have several questions: 1) Does the TestCase structure contain enough members to test all methods? For some of them off1, size1, off2 and size2 are required simultaneously. Also the result may be an integer. 2) May be it would be useful to include the "const char* method_name" member into Test structure to eliminate additional code from the format method? For example, each test may declare its name as a static characters array in the beginning and initialize the method_name structure with pointer to it. Or even add const char* method_name directly into the StringMembers structure. 3) The "#define _RWSTD_TEST_SRC" defintion seems to be missed in the 21.string.cpp, isn't it? Thanks, Anton Pevtsov -----Original Message----- From: sebor@apache.org [mailto:sebor@apache.org]=20 Sent: Thursday, April 20, 2006 04:21 To: stdcxx-commits@incubator.apache.org Subject: svn commit: r395448 - in /incubator/stdcxx/trunk/tests: include/21.strings.h src/21.strings.cpp Author: sebor Date: Wed Apr 19 17:20:46 2006 New Revision: 395448 URL: http://svn.apache.org/viewcvs?rev=3D395448&view=3Drev Log: 2006-04-19 Martin Sebor * 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.st rings.h?rev=3D395448&view=3Dauto =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D --- incubator/stdcxx/trunk/tests/include/21.strings.h (added) +++ incubator/stdcxx/trunk/tests/include/21.strings.h Wed Apr 19=20 +++ 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. + *=20 + ************************************************************************ **/ + +#ifndef RW_21_STRINGS_H_INCLUDED +#define RW_21_STRINGS_H_INCLUDED + +#include + +/********************************************************************** +****/ + +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 =3D append, + // append (const value_type*) + append_ptr =3D 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 =3D append_range, + + // number of member function overloads + append_overloads =3D append_last - append_first, + + ////////////////////////////////////////////////////////////// + assign, + assign_first =3D assign, + // assign (const value_type*) + assign_ptr =3D 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 =3D assign_range, + + // number of member function overloads + assign_overloads =3D assign_last - assign_first, + + ////////////////////////////////////////////////////////////// + insert, + insert_first =3D insert, + // insert (size_type, const value_type*) + insert_off_ptr =3D 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 =3D insert_range, + + // number of member function overloads + insert_overloads =3D insert_last - insert_first, + + ////////////////////////////////////////////////////////////// + replace, + replace_first =3D replace, + // (size_type, size_type, const value_type*) + replace_off_size_ptr =3D 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 =3D replace_range, + + // number of member function overloads + replace_overloads =3D 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 =3D native Propchange: incubator/stdcxx/trunk/tests/include/21.strings.h ------------------------------------------------------------------------ ------ svn:keywords =3D Id Added: incubator/stdcxx/trunk/tests/src/21.strings.cpp URL: http://svn.apache.org/viewcvs/incubator/stdcxx/trunk/tests/src/21.string s.cpp?rev=3D395448&view=3Dauto =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D --- incubator/stdcxx/trunk/tests/src/21.strings.cpp (added) +++ incubator/stdcxx/trunk/tests/src/21.strings.cpp Wed Apr 19 17:20:46=20 +++ 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. + *=20 + ************************************************************************ **/ + +#include <21.strings.h> +#include + +#include + + +static const char* const char_names[] =3D { + "char", "wchar_t", "UserChar" +}; + +static const char* const traits_names[] =3D { + "char_traits", "UserTraits" +}; + +static const char* const allocator_names[] =3D { + "allocator", "UserAllocator" +}; + +static const char* const function_names[] =3D { + "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 =3D 0; + size_t bufsize =3D 0; + + const bool self =3D 0 =3D=3D tcase.arg; + + if ( DefaultTraits =3D=3D tid + && (Char =3D=3D cid || WChar =3D=3D cid)) + rw_asnprintf (&buf, &bufsize, + "std::%{?}w%{;}string (%{?}%{#*s}%{;}).", + WChar =3D=3D cid, + tcase.str !=3D 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 !=3D 0, int (tcase.str_len), = tcase.str); + + const char *fname =3D "assign"; + + switch (which) { + case append_ptr: + fname =3D "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 =3D "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 =3D "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 =3D "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 =3D "append"; + case assign_size_val: + rw_asnprintf (&buf, &bufsize, + "%{+} %s (%zu, %#c)", tcase.size, tcase.val); + break; + + case append_range: + fname =3D "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 =3D native Propchange: incubator/stdcxx/trunk/tests/src/21.strings.cpp ------------------------------------------------------------------------ ------ svn:keywords =3D Id