stdcxx-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elemi...@apache.org
Subject svn commit: r670013 - /stdcxx/branches/4.3.x/tests/utilities/20.tuple.cnstr.cpp
Date Fri, 20 Jun 2008 17:58:45 GMT
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 <eric.lemings@roguewave.com>

	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<UserClass>::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<UserClass>::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<UserClass>::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<UserClass>::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<UserClass>::tuple() called %d default ctors, "
+               "expected 0", UserClass::n_total_def_ctor_);
+    rw_assert (0 == UserClass::n_total_copy_ctor_, __FILE__, __LINE__,
+               "tuple<UserClass>::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<UserClass>::tuple() called %d default ctors, "
+               "expected 2", UserClass::n_total_def_ctor_);
+    rw_assert (0 == UserClass::n_total_copy_ctor_, __FILE__, __LINE__,
+               "tuple<UserClass>::tuple() called %d copy ctors, "
+               "expected 0", UserClass::n_total_copy_ctor_);
+    rw_assert (1 == UserClass::n_total_op_assign_, __FILE__, __LINE__,
+               "tuple<UserClass>::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<UserClass>::tuple() called %d default ctors, "
+               "expected 2", UserClass::n_total_def_ctor_);
+    rw_assert (0 == UserClass::n_total_copy_ctor_, __FILE__, __LINE__,
+               "tuple<UserClass>::tuple() called %d copy ctors, "
+               "expected 0", UserClass::n_total_copy_ctor_);
+    rw_assert (1 == UserClass::n_total_op_assign_, __FILE__, __LINE__,
+               "tuple<UserClass>::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 <rw_allocator.h>           // 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;
 }



Mime
View raw message