Protect test for dynarray under libcpp-no-exceptions
This test expects an exception be thrown. Differential Revision: https://reviews.llvm.org/D26611 git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@288155 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -7,7 +7,6 @@
|
|||||||
//
|
//
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
// XFAIL: libcpp-no-exceptions
|
|
||||||
// UNSUPPORTED: c++98, c++03, c++11
|
// UNSUPPORTED: c++98, c++03, c++11
|
||||||
|
|
||||||
// dynarray.cons
|
// dynarray.cons
|
||||||
@@ -29,6 +28,8 @@
|
|||||||
#include <new>
|
#include <new>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#include "test_macros.h"
|
||||||
|
|
||||||
|
|
||||||
using std::experimental::dynarray;
|
using std::experimental::dynarray;
|
||||||
|
|
||||||
@@ -61,12 +62,14 @@ void test ( const T &val, bool DefaultValueIsIndeterminate = false) {
|
|||||||
assert ( std::all_of ( d3.begin (), d3.end (), [&val]( const T &item ){ return item == val; } ));
|
assert ( std::all_of ( d3.begin (), d3.end (), [&val]( const T &item ){ return item == val; } ));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef TEST_HAS_NO_EXCEPTIONS
|
||||||
void test_bad_length () {
|
void test_bad_length () {
|
||||||
try { dynarray<int> ( std::numeric_limits<size_t>::max() / sizeof ( int ) + 1 ); }
|
try { dynarray<int> ( std::numeric_limits<size_t>::max() / sizeof ( int ) + 1 ); }
|
||||||
catch ( std::bad_array_length & ) { return ; }
|
catch ( std::bad_array_length & ) { return ; }
|
||||||
catch (...) { assert(false); }
|
catch (...) { assert(false); }
|
||||||
assert ( false );
|
assert ( false );
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
@@ -87,5 +90,7 @@ int main()
|
|||||||
assert ( d1.size() == 20 );
|
assert ( d1.size() == 20 );
|
||||||
assert ( std::all_of ( d1.begin (), d1.end (), []( long item ){ return item == 3L; } ));
|
assert ( std::all_of ( d1.begin (), d1.end (), []( long item ){ return item == 3L; } ));
|
||||||
|
|
||||||
|
#ifndef TEST_HAS_NO_EXCEPTIONS
|
||||||
test_bad_length ();
|
test_bad_length ();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user