[libcxx] r245525 - Fix more uses of uninitialized values in dynarray
Eric Fiselier via cfe-commits
cfe-commits at lists.llvm.org
Wed Aug 19 17:10:23 PDT 2015
Author: ericwf
Date: Wed Aug 19 19:10:22 2015
New Revision: 245525
URL: http://llvm.org/viewvc/llvm-project?rev=245525&view=rev
Log:
Fix more uses of uninitialized values in dynarray
Modified:
libcxx/trunk/test/libcxx/experimental/containers/sequences/dynarray/dynarray.data/default.pass.cpp
Modified: libcxx/trunk/test/libcxx/experimental/containers/sequences/dynarray/dynarray.data/default.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/experimental/containers/sequences/dynarray/dynarray.data/default.pass.cpp?rev=245525&r1=245524&r2=245525&view=diff
==============================================================================
--- libcxx/trunk/test/libcxx/experimental/containers/sequences/dynarray/dynarray.data/default.pass.cpp (original)
+++ libcxx/trunk/test/libcxx/experimental/containers/sequences/dynarray/dynarray.data/default.pass.cpp Wed Aug 19 19:10:22 2015
@@ -7,15 +7,13 @@
//
//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++98, c++03, c++11
+
// dynarray.data
// T* data() noexcept;
// const T* data() const noexcept;
-
-#include <__config>
-
-#if _LIBCPP_STD_VER > 11
#include <experimental/dynarray>
#include <cassert>
@@ -27,41 +25,44 @@
using std::experimental::dynarray;
template <class T>
-void dyn_test_const ( const dynarray<T> &dyn ) {
+void dyn_test_const(const dynarray<T> &dyn, bool CheckEquals = true) {
const T *data = dyn.data ();
assert ( data != NULL );
- assert ( std::equal ( dyn.begin(), dyn.end(), data ));
+ if (CheckEquals) {
+ assert ( std::equal ( dyn.begin(), dyn.end(), data ));
}
+}
template <class T>
-void dyn_test ( dynarray<T> &dyn ) {
+void dyn_test( dynarray<T> &dyn, bool CheckEquals = true) {
T *data = dyn.data ();
assert ( data != NULL );
- assert ( std::equal ( dyn.begin(), dyn.end(), data ));
+ if (CheckEquals) {
+ assert ( std::equal ( dyn.begin(), dyn.end(), data ));
}
+}
template <class T>
-void test ( const T &val ) {
+void test(const T &val, bool DefaultValueIsIndeterminate = false) {
typedef dynarray<T> dynA;
+
+ const bool CheckDefaultValues = !DefaultValueIsIndeterminate;
+
+ dynA d1(4);
+ dyn_test(d1, CheckDefaultValues);
+ dyn_test_const(d1, CheckDefaultValues);
- dynA d1 ( 4 );
- dyn_test ( d1 );
- dyn_test_const ( d1 );
-
- dynA d2 ( 7, val );
+ dynA d2 (7, val);
dyn_test ( d2 );
dyn_test_const ( d2 );
- }
+}
int main()
{
- test<int> ( 14 );
- test<double> ( 14.0 );
+ test<int>(14, /* DefaultValueIsIndeterminate */ true);
+ test<double>(14.0, true);
test<std::complex<double>> ( std::complex<double> ( 14, 0 ));
test<std::string> ( "fourteen" );
}
-#else
-int main() {}
-#endif
More information about the cfe-commits
mailing list