From stdcxx-commits-return-1147-apmail-incubator-stdcxx-commits-archive=incubator.apache.org@incubator.apache.org Fri Feb 23 17:04:33 2007 Return-Path: Delivered-To: apmail-incubator-stdcxx-commits-archive@www.apache.org Received: (qmail 37059 invoked from network); 23 Feb 2007 17:04:33 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 23 Feb 2007 17:04:33 -0000 Received: (qmail 82559 invoked by uid 500); 23 Feb 2007 17:04:41 -0000 Delivered-To: apmail-incubator-stdcxx-commits-archive@incubator.apache.org Received: (qmail 82552 invoked by uid 500); 23 Feb 2007 17:04:41 -0000 Mailing-List: contact stdcxx-commits-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-commits@incubator.apache.org Received: (qmail 82541 invoked by uid 99); 23 Feb 2007 17:04:41 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 23 Feb 2007 09:04:41 -0800 X-ASF-Spam-Status: No, hits=-99.5 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 23 Feb 2007 09:04:32 -0800 Received: by eris.apache.org (Postfix, from userid 65534) id 211291A981A; Fri, 23 Feb 2007 09:04:12 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r511019 - in /incubator/stdcxx/trunk/tests: include/23.list.h src/23.containers.cpp Date: Fri, 23 Feb 2007 17:04:11 -0000 To: stdcxx-commits@incubator.apache.org From: faridz@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20070223170412.211291A981A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: faridz Date: Fri Feb 23 09:04:11 2007 New Revision: 511019 URL: http://svn.apache.org/viewvc?view=rev&rev=511019 Log: 2007-02-23 Farid Zaripov ChangeLog: * 23.list.h: New file with definitions of helpers used in clause 23.list tests. * 23.containers.cpp: #included 23.list.h; removed definition of the temporary struct ListIds; _rw_list_sigcat filled by code. Added: incubator/stdcxx/trunk/tests/include/23.list.h (with props) Modified: incubator/stdcxx/trunk/tests/src/23.containers.cpp Added: incubator/stdcxx/trunk/tests/include/23.list.h URL: http://svn.apache.org/viewvc/incubator/stdcxx/trunk/tests/include/23.list.h?view=auto&rev=511019 ============================================================================== --- incubator/stdcxx/trunk/tests/include/23.list.h (added) +++ incubator/stdcxx/trunk/tests/include/23.list.h Fri Feb 23 09:04:11 2007 @@ -0,0 +1,285 @@ +/************************************************************************ +* +* 23.list.h - definitions of helpers used in clause 23.list tests +* +* $Id: 23.list.h +* +*************************************************************************** +* +* Licensed to the Apache Software Foundation (ASF) under one or more +* contributor license agreements. See the NOTICE file distributed +* with this work for additional information regarding copyright +* ownership. The ASF licenses this file to you 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_23_LIST_H_INCLUDED +#define RW_23_LIST_H_INCLUDED + +#include <23.containers.h> + +/**************************************************************************/ + +// defines enumerations identifying list template arguments, +// sets of overloaded functions, member types used in the declarations +// of their signatures, and specific overloads of such member functions +struct ListIds : ContainerIds +{ +// define the helper macros +#include + + // unique identifiers for all overloads of each member function + // 6 bits for FuncId + // 6 * 4 bits for ArgId (at most 6 arguments including this) + // 1 bit for membership + enum OverloadId { + ////////////////////////////////////////////////////////////// + // list () + MEMBER_0 (ctor, cont), + // list (const allocator_type&) + MEMBER_1 (ctor, cont, alloc), + // list (const list&) + MEMBER_1 (ctor, cont, ccont), + // list (size_type) + MEMBER_1 (ctor, cont, size), + // list (size_type, const value_type&) + MEMBER_2 (ctor, cont, size, cref), + // list (size_type, const value_type&, const allocator_type&) + MEMBER_3 (ctor, cont, size, cref, alloc), + // list (InputIterator, InputIterator) + MEMBER_1 (ctor, cont, range), + // list (InputIterator, InputIterator, const allocator&) + MEMBER_2 (ctor, cont, range, alloc), + + ////////////////////////////////////////////////////////////// + // operator= (const list&) + MEMBER_1 (op_set, cont, ccont), + + ////////////////////////////////////////////////////////////// + // assign (size_type, const value_type&) + MEMBER_2 (assign, cont, size, cref), + // assign (InputIterator, InputIterator) + MEMBER_1 (assign, cont, range), + + ////////////////////////////////////////////////////////////// + // get_allocator () const + MEMBER_0 (get_allocator, ccont), + + ////////////////////////////////////////////////////////////// + // begin () + MEMBER_0 (begin, cont), + // begin () const + MEMBER_0 (begin_const, ccont), + // end () + MEMBER_0 (end, cont), + // end () const + MEMBER_0 (end_const, ccont), + + ////////////////////////////////////////////////////////////// + // rbegin () + MEMBER_0 (rbegin, cont), + // rbegin () const + MEMBER_0 (rbegin_const, ccont), + // rend () + MEMBER_0 (rend, cont), + // rend () const + MEMBER_0 (rend_const, ccont), + + ////////////////////////////////////////////////////////////// + // empty () + MEMBER_0 (empty, ccont), + + ////////////////////////////////////////////////////////////// + // size () + MEMBER_0 (size, ccont), + + ////////////////////////////////////////////////////////////// + // max_size () + MEMBER_0 (max_size, ccont), + + ////////////////////////////////////////////////////////////// + // resize (size_type) + MEMBER_1 (resize, cont, size), + // resize (size_type, value_type) + MEMBER_2 (resize, cont, size, val), + + ////////////////////////////////////////////////////////////// + // front () + MEMBER_0 (front, cont), + // front () const + MEMBER_0 (front_const, ccont), + // back () + MEMBER_0 (back, cont), + // back () const + MEMBER_0 (back_const, ccont), + + ////////////////////////////////////////////////////////////// + // push_front (const value_type&) + MEMBER_1 (push_front, cont, cref), + // pop_front () + MEMBER_0 (pop_front, cont), + // push_back (const value_type&) + MEMBER_1 (push_back, cont, cref), + // pop_back () + MEMBER_0 (pop_back, cont), + + ////////////////////////////////////////////////////////////// + // insert (iterator, const value_type&) + MEMBER_2 (insert, cont, iter, cref), + // insert (iterator, size_type, const value_type&) + MEMBER_3 (insert, cont, iter, size, cref), + // insert (iterator, InputIterator, InputIterator) + MEMBER_2 (insert, cont, iter, range), + + ////////////////////////////////////////////////////////////// + // erase (iterator) + MEMBER_1 (erase, cont, iter), + // erase (iterator, iterator) + MEMBER_2 (erase, cont, iter, iter), + + ////////////////////////////////////////////////////////////// + // swap (list&) + MEMBER_1 (swap, cont, cont), + // swap (list&, list&) + NON_MEMBER_2 (swap, cont, cont), + + ////////////////////////////////////////////////////////////// + // clear () + MEMBER_0 (clear, cont), + + ////////////////////////////////////////////////////////////// + // splice (iterator, list&) + MEMBER_2 (splice, cont, iter, cont), + // splice (iterator, list&, iterator) + MEMBER_3 (splice, cont, iter, cont, iter), + // splice (iterator, list&, iterator, iterator) + MEMBER_4 (splice, cont, iter, cont, iter, iter), + + ////////////////////////////////////////////////////////////// + // remove (const value_type&) + MEMBER_1 (remove, cont, cref), + // remove_if (Predicate) + MEMBER_1 (remove_if, cont, pred), + + ////////////////////////////////////////////////////////////// + // unique (BinaryPredicate) + MEMBER_1 (unique, cont, bpred), + + ////////////////////////////////////////////////////////////// + // merge (list&) + MEMBER_1 (merge, cont, cont), + // merge (list&, Compare) + MEMBER_2 (merge, cont, cont, comp), + + ////////////////////////////////////////////////////////////// + // sort () + MEMBER_0 (sort, cont), + // sort (Compare) + MEMBER_1 (sort, cont, comp), + + ////////////////////////////////////////////////////////////// + // reverse () + MEMBER_0 (reverse, cont), + + ////////////////////////////////////////////////////////////// + // operator== (const list&, const list&) + NON_MEMBER_2 (op_equal, ccont, ccont), + + ////////////////////////////////////////////////////////////// + // operator< (const list&, const list&) + NON_MEMBER_2 (op_less, ccont, ccont), + + ////////////////////////////////////////////////////////////// + // operator!= (const list&, const list&) + NON_MEMBER_2 (op_not_equal, ccont, ccont), + + ////////////////////////////////////////////////////////////// + // operator> (const list&, const list&) + NON_MEMBER_2 (op_greater, ccont, ccont), + + ////////////////////////////////////////////////////////////// + // operator>= (const list&, const list&) + NON_MEMBER_2 (op_greater_equal, ccont, ccont), + + ////////////////////////////////////////////////////////////// + // operator<= (const list&, const list&) + NON_MEMBER_2 (op_less_equal, ccont, ccont) + }; + +// clean up helper macros used above +#include + +}; + +/**************************************************************************/ + +template +static inline bool +_rw_equal (InputIter1 first1, InputIter1 last1, InputIter2 first2) +{ + for (; first1 != last1 && *first1 == *first2; ++first1, ++first2) ; + + return first1 == last1; +} + +// encapsulates the state of a list object +// used in exception safety tests to determine changes to the state +// after a modifying operation throws an exception +template +struct ListState +{ + typedef typename List::const_iterator ListCIter; + typedef typename List::const_pointer ListCPtr; + + _RWSTD_SIZE_T size_; + ListCIter* iters_; + ListCPtr* ptrs_; + + ListState (List const & lst) : size_ (lst.size ()), iters_ (0), ptrs_ (0) + { + iters_ = new ListCIter [size_]; + ptrs_ = new ListCPtr [size_]; + + _RWSTD_SIZE_T index = 0; + for (ListCIter it = lst.begin (), end = lst.end (); + it != end; ++it, ++index) { + + iters_ [index] = it; + ptrs_ [index] = &*it; + } + } + + ~ListState () + { + delete [] iters_; + delete [] ptrs_; + } + + // invokes rw_assert() to verify that two states are the same + void assert_equal (const ListState& state, int line, + int case_line, const char* when) const + { + const int equal = size_ == state.size_ + && _rw_equal (iters_, iters_ + size_, state.iters_) + && _rw_equal (ptrs_, ptrs_ + size_, state.ptrs_); + + rw_assert (equal, 0, case_line, + "line %d: %{$FUNCALL}: object state unexpectedly changed " + "after %s", line, when); + } +}; + +/**************************************************************************/ + +#endif // RW_23_LIST_H_INCLUDED Propchange: incubator/stdcxx/trunk/tests/include/23.list.h ------------------------------------------------------------------------------ svn:eol-style = native Propchange: incubator/stdcxx/trunk/tests/include/23.list.h ------------------------------------------------------------------------------ svn:keywords = Id Modified: incubator/stdcxx/trunk/tests/src/23.containers.cpp URL: http://svn.apache.org/viewvc/incubator/stdcxx/trunk/tests/src/23.containers.cpp?view=diff&rev=511019&r1=511018&r2=511019 ============================================================================== --- incubator/stdcxx/trunk/tests/src/23.containers.cpp (original) +++ incubator/stdcxx/trunk/tests/src/23.containers.cpp Fri Feb 23 09:04:11 2007 @@ -30,6 +30,7 @@ #include // for allocator #include <23.containers.h> +#include <23.list.h> #include // for rw_enabled() #include // for UserAlloc @@ -344,19 +345,174 @@ /**************************************************************************/ -// temporary, shuld be defined in 23.list.h -struct ListIds : ContainerIds -{ - enum OverloadId {}; -}; - static void _rw_list_sigcat (char** pbuf, size_t * pbufsize, ListIds::OverloadId which, bool self, const char* str, size_t str_len, const char* arg, size_t arg_len, const ContainerTestCase &tcase) { - // temporary empty + // compute the end offsets for convenience + const size_t range1_end = tcase.off + tcase.size; + const size_t range2_end = tcase.off2 + tcase.size2; + + // determine whether the function takes an allocator_type argument + const bool use_alloc = 0 < _rw_argno (which, ContainerIds::arg_alloc); + + // format and append cont function arguments abbreviating complex + // expressions as much as possible to make them easy to understand + switch (which) { + case ListIds::ctor_ccont: + case ListIds::op_set_ccont: + case ListIds::swap_cont: + case ListIds::merge_cont: + // format self-referential cont argument as *this + rw_asnprintf (pbuf, pbufsize, + "%{+} (%{?}*this%{:}%{$Container}(%{#*s})%{;}" + "%{?}, const allocator_type&%{;})", + self, int (arg_len), arg, use_alloc); + break; + + case ListIds::assign_size_cref: + case ListIds::ctor_size_cref: + case ListIds::ctor_size_cref_alloc: + rw_asnprintf (pbuf, pbufsize, + "%{+} (%zu, %{#c}%{?}, const allocator_type&%{;})", + tcase.size, tcase.val, use_alloc); + break; + + case ListIds::assign_range: + case ListIds::ctor_range: + case ListIds::ctor_range_alloc: + rw_asnprintf (pbuf, pbufsize, "%{+}<%{$Iterator:-Iterator}>(" + "%{?}begin()%{:}%{$Iterator:-Iterator}(%{#*s})%{;}" + "%{?} + %zu%{;}, " + "%{?}begin()%{:}%{$Iterator:-Iterator}(...)%{;}" + "%{?} + %zu%{;}" + "%{?}, const allocator_type&%{;})", + self, int (arg_len), arg, + 0 != tcase.off2, tcase.off2, + self, 0 != range2_end, range2_end, use_alloc); + break; + + case ListIds::insert_iter_cref: + rw_asnprintf (pbuf, pbufsize, + "%{+} (begin()%{?} + %zu%{;}, %{#c})", + 0 != tcase.off, tcase.off, tcase.val); + break; + + case ListIds::insert_iter_size_cref: + rw_asnprintf (pbuf, pbufsize, + "%{+} (begin()%{?} + %zu%{;}, %zu, %{#c})", + 0 != tcase.off, tcase.off, tcase.size, tcase.val); + break; + + case ListIds::insert_iter_range: + rw_asnprintf (pbuf, pbufsize, "%{+}<%{$Iterator:-Iterator}>" + "(begin()%{?} + %zu%{;}, " + "%{?}begin()%{:}%{$Iterator:-Iterator}(%{#*s})%{;}" + "%{?} + %zu%{;}, " + "%{?}begin()%{:}%{$Iterator:-Iterator}(...)%{;}" + "%{?} + %zu%{;})", + 0 != tcase.off, tcase.off, + self, int (arg_len), arg, + 0 != tcase.off2, tcase.off2, + self, 0 != range2_end, range2_end); + break; + + case ListIds::push_front_cref: + case ListIds::push_back_cref: + case ListIds::remove_cref: + rw_asnprintf (pbuf, pbufsize, + "%{+} (%{#c})", tcase.val); + break; + + case ListIds::ctor_void: + case ListIds::get_allocator_void: + case ListIds::begin_void: + case ListIds::end_void: + case ListIds::rbegin_void: + case ListIds::rend_void: + case ListIds::empty_void: + case ListIds::size_void: + case ListIds::max_size_void: + case ListIds::front_void: + case ListIds::back_void: + case ListIds::pop_front_void: + case ListIds::pop_back_void: + case ListIds::clear_void: + case ListIds::sort_void: + case ListIds::reverse_void: + rw_asnprintf (pbuf, pbufsize, + "%{+} ()"); + break; + + case ListIds::begin_const_void: + case ListIds::end_const_void: + case ListIds::rbegin_const_void: + case ListIds::rend_const_void: + case ListIds::front_const_void: + case ListIds::back_const_void: + rw_asnprintf (pbuf, pbufsize, + "%{+} () const"); + break; + + case ListIds::ctor_alloc: + rw_asnprintf (pbuf, pbufsize, + "%{+} (const allocator_type&)"); + break; + + case ListIds::erase_iter: + rw_asnprintf (pbuf, pbufsize, + "%{+} (begin()%{?} + %zu%{;})", + 0 != tcase.off, tcase.off); + break; + + case ListIds::erase_iter_iter: + rw_asnprintf (pbuf, pbufsize, + "%{+} (begin()%{?} + %zu%{;}, begin()%{?} + %zu%{;})", + 0 != tcase.off, tcase.off, + 0 != range1_end, range1_end); + break; + + case ListIds::op_equal_ccont_ccont: + case ListIds::op_less_ccont_ccont: + case ListIds::op_not_equal_ccont_ccont: + case ListIds::op_greater_ccont_ccont: + case ListIds::op_greater_equal_ccont_ccont: + case ListIds::op_less_equal_ccont_ccont: + // format zero cont argument without size as arg + rw_asnprintf (pbuf, pbufsize, + "%{+} (%{?}arg2%{:}%{$CLASS}(%{#*s})%{;}, " + "%{?}arg1%{:}%{$CLASS}(%{#*s})%{;})", + 0 == str, int (str_len), str, self, int (arg_len), arg); + break; + + case ListIds::ctor_size: + case ListIds::resize_size: + rw_asnprintf (pbuf, pbufsize, + "%{+} (%zu)", tcase.size); + break; + + case ListIds::resize_size_val: + rw_asnprintf (pbuf, pbufsize, + "%{+} (%zu, %{#c})", tcase.size, tcase.val); + break; + + case ListIds::swap_cont_cont: + case ListIds::splice_iter_cont: + case ListIds::splice_iter_cont_iter: + case ListIds::splice_iter_cont_iter_iter: + case ListIds::remove_if_pred: + case ListIds::unique_bpred: + case ListIds::merge_cont_comp: + case ListIds::sort_comp: + rw_asnprintf (pbuf, pbufsize, + "not yet defined"); + break; + + default: + RW_ASSERT (!"test logic error: unknown list overload"); + } } /**************************************************************************/