stdcxx-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From far...@apache.org
Subject svn commit: r544793 - /incubator/stdcxx/trunk/tests/regress/23.list.cons.stdcxx-268.cpp
Date Wed, 06 Jun 2007 10:04:30 GMT
Author: faridz
Date: Wed Jun  6 03:04:30 2007
New Revision: 544793

URL: http://svn.apache.org/viewvc?view=rev&rev=544793
Log:
2007-06-06 Farid Zaripov <Farid_Zaripov@epam.com>

	* 23.list.cons.stdcxx-268.cpp: new test from STDCXX-268 issue

Added:
    incubator/stdcxx/trunk/tests/regress/23.list.cons.stdcxx-268.cpp   (with props)

Added: incubator/stdcxx/trunk/tests/regress/23.list.cons.stdcxx-268.cpp
URL: http://svn.apache.org/viewvc/incubator/stdcxx/trunk/tests/regress/23.list.cons.stdcxx-268.cpp?view=auto&rev=544793
==============================================================================
--- incubator/stdcxx/trunk/tests/regress/23.list.cons.stdcxx-268.cpp (added)
+++ incubator/stdcxx/trunk/tests/regress/23.list.cons.stdcxx-268.cpp Wed Jun  6 03:04:30 2007
@@ -0,0 +1,118 @@
+/************************************************************************
+ *
+ * 23.list.cons.stdcxx-268.cpp - test case from STDCXX-268 issue
+ *
+ * $Id$
+ *
+ ***************************************************************************
+ *
+ * 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.
+ * 
+ **************************************************************************/
+
+#include <list>
+#include <cassert>
+
+static int throw_inx = -1;
+
+class ListItem
+{
+public:
+    static int count_;
+
+    void test ()
+    {
+        if (throw_inx == count_)
+            throw count_;
+
+        ++count_;
+    }
+
+    ListItem () { test (); }
+
+    ListItem (const ListItem&) { test (); }
+
+    ~ListItem () { --count_; }
+};
+
+int ListItem::count_ = 0;
+
+int main(int argc, char* argv[])
+{
+    typedef std::list<ListItem> List;
+    ListItem items [20];
+    List lst (20);
+
+    bool thrown = false;
+    throw_inx = 10;
+
+    try {
+        ListItem::count_ = 0;
+        List test (20);
+    } catch (...) {
+        thrown = true;
+    }
+
+    assert (thrown);
+    assert (0 == ListItem::count_);
+
+    try {
+        thrown = false;
+        ListItem::count_ = 0;
+        List test (20, items [0]);
+    } catch (...) {
+        thrown = true;
+    }
+
+    assert (thrown);
+    assert (0 == ListItem::count_);
+
+    try {
+        thrown = false;
+        ListItem::count_ = 0;
+        List test (items, items + 20);
+    } catch (...) {
+        thrown = true;
+    }
+
+    assert (thrown);
+    assert (0 == ListItem::count_);
+
+    try {
+        thrown = false;
+        ListItem::count_ = 0;
+        List test (lst.begin (), lst.end ());
+    } catch (...) {
+        thrown = true;
+    }
+
+    assert (thrown);
+    assert (0 == ListItem::count_);
+
+    try {
+        thrown = false;
+        ListItem::count_ = 0;
+        List test (lst);
+    } catch (...) {
+        thrown = true;
+    }
+
+    assert (thrown);
+    assert (0 == ListItem::count_);
+
+    return 0;
+}

Propchange: incubator/stdcxx/trunk/tests/regress/23.list.cons.stdcxx-268.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/stdcxx/trunk/tests/regress/23.list.cons.stdcxx-268.cpp
------------------------------------------------------------------------------
    svn:keywords = Id



Mime
View raw message