stdcxx-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From far...@apache.org
Subject svn commit: r1291062 - in /stdcxx/branches/4.2.x: include/vector tests/regress/23.vector.bool.stdcxx-1062.cpp
Date Sun, 19 Feb 2012 21:14:01 GMT
Author: faridz
Date: Sun Feb 19 21:14:00 2012
New Revision: 1291062

URL: http://svn.apache.org/viewvc?rev=1291062&view=rev
Log:
2012-02-19 Farid Zaripov <faridz@apache.com>

	STDCXX-1062
	* include/vector (operator[], at): Throw std::out_of_range instead of std::length_error.
	* tests/regress/23.vector.bool.stdcxx-1062.cpp: New regression test is added.

Added:
    stdcxx/branches/4.2.x/tests/regress/23.vector.bool.stdcxx-1062.cpp   (with props)
Modified:
    stdcxx/branches/4.2.x/include/vector

Modified: stdcxx/branches/4.2.x/include/vector
URL: http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/include/vector?rev=1291062&r1=1291061&r2=1291062&view=diff
==============================================================================
--- stdcxx/branches/4.2.x/include/vector (original)
+++ stdcxx/branches/4.2.x/include/vector Sun Feb 19 21:14:00 2012
@@ -1237,7 +1237,7 @@ public:
 #ifdef _RWSTD_BOUNDS_CHECKING
 
         _RWSTD_REQUIRES (__n < size (),
-                         (_RWSTD_ERROR_LENGTH_ERROR,
+                         (_RWSTD_ERROR_OUT_OF_RANGE,
                           _RWSTD_FUNC ("vector<bool>::[](size_type)"),
                           __n, size ()));
 
@@ -1250,7 +1250,7 @@ public:
 #ifdef _RWSTD_BOUNDS_CHECKING
 
         _RWSTD_REQUIRES (__n < size (),
-                         (_RWSTD_ERROR_LENGTH_ERROR,
+                         (_RWSTD_ERROR_OUT_OF_RANGE,
                           _RWSTD_FUNC ("vector<bool>::[](size_type)"),
                           __n, size ()));
 
@@ -1261,7 +1261,7 @@ public:
     reference       at (size_type __n)               
     { 
         _RWSTD_REQUIRES (__n < size (),
-                         (_RWSTD_ERROR_LENGTH_ERROR,
+                         (_RWSTD_ERROR_OUT_OF_RANGE,
                           _RWSTD_FUNC ("vector<bool>::at(size_type)"),
                           __n, size ()));
       return *(begin() + __n); 
@@ -1269,7 +1269,7 @@ public:
     const_reference at (size_type __n)   const 
     {
         _RWSTD_REQUIRES (__n < size (),
-                         (_RWSTD_ERROR_LENGTH_ERROR,
+                         (_RWSTD_ERROR_OUT_OF_RANGE,
                           _RWSTD_FUNC ("vector<bool>::at(size_type) const"),
                           __n, size ()));
 

Added: stdcxx/branches/4.2.x/tests/regress/23.vector.bool.stdcxx-1062.cpp
URL: http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/tests/regress/23.vector.bool.stdcxx-1062.cpp?rev=1291062&view=auto
==============================================================================
--- stdcxx/branches/4.2.x/tests/regress/23.vector.bool.stdcxx-1062.cpp (added)
+++ stdcxx/branches/4.2.x/tests/regress/23.vector.bool.stdcxx-1062.cpp Sun Feb 19 21:14:00
2012
@@ -0,0 +1,60 @@
+/************************************************************************
+*
+* 23.vector.bool.stdcxx-1062.cpp - regression test for STDCXX-1062
+*
+* https://issues.apache.org/jira/browse/STDCXX-1062
+*
+* $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.
+*
+**************************************************************************/
+
+#define _RWSTD_BOUNDS_CHECKING
+
+#include <cassert>
+#include <vector>
+#include <stdexcept>
+
+int main()
+{
+    std::vector<bool> v(1);
+
+    try {
+        v.at (v.size());
+        assert (!"Expect std::out_of_range, got nothing");
+    }
+    catch (const std::out_of_range&) {
+    }
+    catch ( ... ) {
+        assert (!"Expect out_of_range, got other exception");
+    }
+
+    try {
+        v [v.size()];
+        assert (!"Expect std::out_of_range, got nothing");
+    }
+    catch (const std::out_of_range&) {
+    }
+    catch ( ... ) {
+        assert (!"Expect out_of_range, got other exception");
+    }
+
+    return 0;
+}

Propchange: stdcxx/branches/4.2.x/tests/regress/23.vector.bool.stdcxx-1062.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: stdcxx/branches/4.2.x/tests/regress/23.vector.bool.stdcxx-1062.cpp
------------------------------------------------------------------------------
    svn:keywords = Id



Mime
View raw message