Return-Path: Delivered-To: apmail-stdcxx-commits-archive@www.apache.org Received: (qmail 56517 invoked from network); 20 Jun 2008 17:59:06 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 20 Jun 2008 17:59:06 -0000 Received: (qmail 43539 invoked by uid 500); 20 Jun 2008 17:59:08 -0000 Delivered-To: apmail-stdcxx-commits-archive@stdcxx.apache.org Received: (qmail 43511 invoked by uid 500); 20 Jun 2008 17:59:08 -0000 Mailing-List: contact commits-help@stdcxx.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@stdcxx.apache.org Delivered-To: mailing list commits@stdcxx.apache.org Received: (qmail 43502 invoked by uid 99); 20 Jun 2008 17:59:08 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 20 Jun 2008 10:59:08 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 20 Jun 2008 17:58:26 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 9795823889F1; Fri, 20 Jun 2008 10:58:45 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r670013 - /stdcxx/branches/4.3.x/tests/utilities/20.tuple.cnstr.cpp Date: Fri, 20 Jun 2008 17:58:45 -0000 To: commits@stdcxx.apache.org From: elemings@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080620175845.9795823889F1@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: elemings Date: Fri Jun 20 10:58:45 2008 New Revision: 670013 URL: http://svn.apache.org/viewvc?rev=670013&view=rev Log: 2008-06-20 Eric Lemings STDCXX-958 * tests/utilities/20.tuple.cnstr.cpp (test_default_ctor): (test_value_copy_ctor, test_value_move_ctor, test_homo_copy_ctor): Fix assertions for total # of UserClass copy ctors called. (test_homo_move_ctor, test_homo_copy_assign): (test_homo_move_assign, test_hetero_copy_ctor): Added new tests. (test_hetero_move_ctor, test_hetero_copy_assign): (test_hetero_move_assign, test_alloc_ctors): Added outline for remaining tests. Modified: stdcxx/branches/4.3.x/tests/utilities/20.tuple.cnstr.cpp Modified: stdcxx/branches/4.3.x/tests/utilities/20.tuple.cnstr.cpp URL: http://svn.apache.org/viewvc/stdcxx/branches/4.3.x/tests/utilities/20.tuple.cnstr.cpp?rev=670013&r1=670012&r2=670013&view=diff ============================================================================== --- stdcxx/branches/4.3.x/tests/utilities/20.tuple.cnstr.cpp (original) +++ stdcxx/branches/4.3.x/tests/utilities/20.tuple.cnstr.cpp Fri Jun 20 10:58:45 2008 @@ -1,6 +1,6 @@ /*************************************************************************** * - * 20.tuple.cnstr.cpp - tests exercising tuple constructors and other members + * 20.tuple.cnstr.cpp - tests exercising tuple constructors and operators * * $Id$ * @@ -22,7 +22,7 @@ * implied. See the License for the specific language governing * permissions and limitations under the License. * - * Copyright 1994-2008 Rogue Wave Software. + * Copyright 2008 Rogue Wave Software. * **************************************************************************/ @@ -54,7 +54,7 @@ "expected 1", UserClass::n_total_def_ctor_); rw_assert (0 == UserClass::n_total_copy_ctor_, __FILE__, __LINE__, "tuple::tuple() called %d copy ctors, " - "expected 0", UserClass::n_total_def_ctor_); + "expected 0", UserClass::n_total_copy_ctor_); } /**************************************************************************/ @@ -82,7 +82,7 @@ "expected 1", UserClass::n_total_def_ctor_); rw_assert (1 == UserClass::n_total_copy_ctor_, __FILE__, __LINE__, "tuple::tuple() called %d copy ctors, " - "expected 1", UserClass::n_total_def_ctor_); + "expected 1", UserClass::n_total_copy_ctor_); const bool b = true; const char c = 'a'; const double d = 1.2; void* const p = 0; @@ -112,7 +112,7 @@ "expected 0", UserClass::n_total_def_ctor_); rw_assert (0 == UserClass::n_total_copy_ctor_, __FILE__, __LINE__, "tuple::tuple() called %d copy ctors, " - "expected 0", UserClass::n_total_def_ctor_); + "expected 0", UserClass::n_total_copy_ctor_); } /**************************************************************************/ @@ -120,7 +120,8 @@ static void test_homo_copy_ctor () { - rw_info (0, __FILE__, __LINE__, "copy constructor (homogenous tuples)"); + rw_info (0, __FILE__, __LINE__, + "copy constructor (homogenous tuples)"); EmptyTuple et1, et2 (et1); _RWSTD_UNUSED (et2); @@ -146,7 +147,7 @@ "expected 1", UserClass::n_total_def_ctor_); rw_assert (1 == UserClass::n_total_copy_ctor_, __FILE__, __LINE__, "tuple::tuple() called %d copy ctors, " - "expected 1", UserClass::n_total_def_ctor_); + "expected 1", UserClass::n_total_copy_ctor_); const BigTuple bt1; BigTuple bt2 (bt1); _RWSTD_UNUSED (bt1); _RWSTD_UNUSED (bt2); @@ -154,6 +155,174 @@ /**************************************************************************/ +static void +test_homo_move_ctor () +{ + rw_info (0, __FILE__, __LINE__, + "move constructor (homogenous tuples)"); + + EmptyTuple et (EmptyTuple ()); _RWSTD_UNUSED (et); + IntTuple it (IntTuple ()); _RWSTD_UNUSED (it); + ConstIntTuple ct (ConstIntTuple ()); _RWSTD_UNUSED (ct); + PairTuple pt (PairTuple ()); _RWSTD_UNUSED (pt); + NestedTuple nt (NestedTuple ()); _RWSTD_UNUSED (nt); + BigTuple bt (BigTuple ()); + + UserClass::reset_totals (); + UserTuple ut (UserTuple ()); + rw_assert (0 == UserClass::n_total_def_ctor_, __FILE__, __LINE__, + "tuple::tuple() called %d default ctors, " + "expected 0", UserClass::n_total_def_ctor_); + rw_assert (0 == UserClass::n_total_copy_ctor_, __FILE__, __LINE__, + "tuple::tuple() called %d copy ctors, " + "expected 0", UserClass::n_total_copy_ctor_); +} + +/**************************************************************************/ + +static void +test_homo_copy_assign () +{ + rw_info (0, __FILE__, __LINE__, + "copy assignment operator (homogenous tuples)"); + + EmptyTuple et1, et2; et2 = et1; + IntTuple it1, it2; it2 = it1; + //ConstIntTuple ct1, ct2; ct2 = ct1; // Can't assign to const element. + PairTuple pt1, pt2; pt2 = pt1; + NestedTuple nt1, nt2; nt2 = nt1; + BigTuple bt1, bt2; bt2 = bt1; + + UserClass::reset_totals (); + UserTuple ut1, ut2; ut1 = ut2; + rw_assert (2 == UserClass::n_total_def_ctor_, __FILE__, __LINE__, + "tuple::tuple() called %d default ctors, " + "expected 2", UserClass::n_total_def_ctor_); + rw_assert (0 == UserClass::n_total_copy_ctor_, __FILE__, __LINE__, + "tuple::tuple() called %d copy ctors, " + "expected 0", UserClass::n_total_copy_ctor_); + rw_assert (1 == UserClass::n_total_op_assign_, __FILE__, __LINE__, + "tuple::tuple() called %d assign ops, " + "expected 1", UserClass::n_total_op_assign_); +} + +/**************************************************************************/ + +static void +test_homo_move_assign () +{ + rw_info (0, __FILE__, __LINE__, + "move assignment operator (homogenous tuples)"); + + EmptyTuple et1, et2; et2 = et1; + IntTuple it1, it2; it2 = it1; + //ConstIntTuple ct1, ct2; ct2 = ct1; // Can't assign to const element. + PairTuple pt1, pt2; pt2 = pt1; + NestedTuple nt1, nt2; nt2 = nt1; + BigTuple bt1, bt2; bt2 = bt1; + + UserClass::reset_totals (); + UserTuple ut1, ut2; ut1 = ut2; + rw_assert (2 == UserClass::n_total_def_ctor_, __FILE__, __LINE__, + "tuple::tuple() called %d default ctors, " + "expected 2", UserClass::n_total_def_ctor_); + rw_assert (0 == UserClass::n_total_copy_ctor_, __FILE__, __LINE__, + "tuple::tuple() called %d copy ctors, " + "expected 0", UserClass::n_total_copy_ctor_); + rw_assert (1 == UserClass::n_total_op_assign_, __FILE__, __LINE__, + "tuple::tuple() called %d assign ops, " + "expected 1", UserClass::n_total_op_assign_); +} + +/**************************************************************************/ + +static void +test_hetero_copy_ctor () +{ + rw_info (0, __FILE__, __LINE__, + "copy constructor (heterogenous tuples)"); + + const int i1 = 0; const char c = 'a'; const double d = 1.2; + void* const p = 0; UserClass uc; + BigTuple bt1 (i1, c, i1, d, p, uc); _RWSTD_UNUSED (bt1); + + const bool b = true; const int i2 = 'a'; + BigTuple bt2 (b, i2, i1, d, p, uc); _RWSTD_UNUSED (bt2); + + const float f = 1.2; + BigTuple bt3 (b, c, i1, f, p, uc); _RWSTD_UNUSED (bt3); + + //UserTuple +} + +/**************************************************************************/ + +static void +test_hetero_move_ctor () +{ + rw_info (0, __FILE__, __LINE__, + "move constructor (heterogenous tuples)"); + + //EmptyTuple + //IntTuple + //ConstIntTuple; + //PairTuple + //NestedTuple + + //UserTuple + // BigTuple +} + +/**************************************************************************/ + +static void +test_hetero_copy_assign () +{ + rw_info (0, __FILE__, __LINE__, + "copy assignment operator (heterogenous tuples)"); + + //EmptyTuple + //IntTuple + //ConstIntTuple; + //PairTuple + //NestedTuple + + //UserTuple + // BigTuple +} + +/**************************************************************************/ + +static void +test_hetero_move_assign () +{ + rw_info (0, __FILE__, __LINE__, + "move assignment operator (heterogenous tuples)"); + + //EmptyTuple + //IntTuple + //ConstIntTuple; + //PairTuple + //NestedTuple + + //UserTuple + // BigTuple +} + +/**************************************************************************/ + +#include // for UserAlloc + +static void +test_alloc_ctors () +{ + rw_info (0, __FILE__, __LINE__, + "user-defined allocator constructors"); + +} + +/**************************************************************************/ + static int run_test (int /*unused*/, char* /*unused*/ []) { @@ -163,16 +332,16 @@ test_value_move_ctor (); test_homo_copy_ctor (); - //test_homo_move_ctor (); - //test_homo_copy_assign (); - //test_homo_move_assign (); - - //test_hetero_copy_ctor (); - //test_hetero_move_ctor (); - //test_hetero_copy_assign (); - //test_hetero_move_assign (); + test_homo_move_ctor (); + test_homo_copy_assign (); + test_homo_move_assign (); + + test_hetero_copy_ctor (); + test_hetero_move_ctor (); + test_hetero_copy_assign (); + test_hetero_move_assign (); - //test_alloc_ctors (); + test_alloc_ctors (); return 0; }