|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r85511 - in branches/release: boost libs/any libs/any/test
From: antoshkka_at_[hidden]
Date: 2013-08-29 07:30:58
Author: apolukhin
Date: 2013-08-29 07:30:58 EDT (Thu, 29 Aug 2013)
New Revision: 85511
URL: http://svn.boost.org/trac/boost/changeset/85511
Log:
Merge tests of Boost.Any from trunk (refs #6999)
Added:
branches/release/libs/any/test/any_test_cv_to_rv_failed.cpp
- copied unchanged from r85233, trunk/libs/any/test/any_test_cv_to_rv_failed.cpp
branches/release/libs/any/test/any_test_temporary_to_ref_failed.cpp
- copied unchanged from r85233, trunk/libs/any/test/any_test_temporary_to_ref_failed.cpp
Properties modified:
branches/release/boost/any.hpp (props changed)
branches/release/libs/any/ (props changed)
Text files modified:
branches/release/libs/any/any_test.cpp | 42 ++++++++++++++++++++++++++++++---------
branches/release/libs/any/test/Jamfile.v2 | 2 +
branches/release/libs/any/test/any_test_cv_to_rv_failed.cpp | 39 +++++++++++++++++++++++++++++++++++++
branches/release/libs/any/test/any_test_temporary_to_ref_failed.cpp | 38 ++++++++++++++++++++++++++++++++++++
4 files changed, 111 insertions(+), 10 deletions(-)
Modified: branches/release/libs/any/any_test.cpp
==============================================================================
--- branches/release/libs/any/any_test.cpp Thu Aug 29 04:39:09 2013 (r85510)
+++ branches/release/libs/any/any_test.cpp 2013-08-29 07:30:58 EDT (Thu, 29 Aug 2013) (r85511)
@@ -1,6 +1,6 @@
// what: unit tests for variant type boost::any
// who: contributed by Kevlin Henney
-// when: July 2001
+// when: July 2001, 2013
// where: tested with BCC 5.5, MSVC 6.0, and g++ 2.95
#include <cstdlib>
@@ -38,6 +38,7 @@
void test_cast_to_reference();
void test_with_array();
void test_with_func();
+ void test_clear();
const test_case test_cases[] =
{
@@ -51,7 +52,8 @@
{ "copying operations on a null", test_null_copying },
{ "cast to reference types", test_cast_to_reference },
{ "storing an array inside", test_with_array },
- { "implicit cast of returned value",test_with_func }
+ { "implicit cast of returned value",test_with_func },
+ { "clear() methods", test_clear }
};
const test_case_iterator begin = test_cases;
@@ -286,26 +288,46 @@
std::string s;
s = any_cast<std::string>(returning_string1());
s = any_cast<const std::string&>(returning_string1());
- //s = any_cast<std::string&>(returning_string1());
s = any_cast<std::string>(returning_string2());
s = any_cast<const std::string&>(returning_string2());
- //s = any_cast<std::string&>(returning_string2());
-#if !defined(_MSC_VER) || _MSC_VER != 1600
-#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
- //s = static_cast<std::string&&>(any_cast<std::string&>(returning_string1()));
+#if (!defined(_MSC_VER) || _MSC_VER != 1600) && !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
+#if !defined(__INTEL_COMPILER) && !defined(__ICL)
+ // Intel compiler thinks that it must choose the `any_cast(const any&)` function
+ // instead of the `any_cast(const any&&)`.
+ // Bug was not reported because of missing premier support account + annoying
+ // registrations requirements.
s = any_cast<std::string&&>(returning_string1());
-
- //s = static_cast<std::string&&>(any_cast<std::string&>(returning_string2()));
- s = any_cast<std::string&&>(returning_string2());
#endif
+ s = any_cast<std::string&&>(returning_string2());
#endif
}
+
+ void test_clear()
+ {
+ std::string text = "test message";
+ any value = text;
+
+ check_false(value.empty(), "empty");
+
+ value.clear();
+ check_true(value.empty(), "non-empty after clear");
+
+ value.clear();
+ check_true(value.empty(), "non-empty after second clear");
+
+ value = text;
+ check_false(value.empty(), "empty");
+
+ value.clear();
+ check_true(value.empty(), "non-empty after clear");
+ }
}
// Copyright Kevlin Henney, 2000, 2001. All rights reserved.
+// Copyright Antony Polukhin, 2013.
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
Modified: branches/release/libs/any/test/Jamfile.v2
==============================================================================
--- branches/release/libs/any/test/Jamfile.v2 Thu Aug 29 04:39:09 2013 (r85510)
+++ branches/release/libs/any/test/Jamfile.v2 2013-08-29 07:30:58 EDT (Thu, 29 Aug 2013) (r85511)
@@ -10,6 +10,8 @@
[ run ../any_test.cpp ]
[ run any_test_rv.cpp ]
[ compile-fail any_cast_cv_failed.cpp ]
+ [ compile-fail any_test_temporary_to_ref_failed.cpp ]
+ [ compile-fail any_test_cv_to_rv_failed.cpp ]
;
Copied: branches/release/libs/any/test/any_test_cv_to_rv_failed.cpp (from r85233, trunk/libs/any/test/any_test_cv_to_rv_failed.cpp)
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ branches/release/libs/any/test/any_test_cv_to_rv_failed.cpp 2013-08-29 07:30:58 EDT (Thu, 29 Aug 2013) (r85511, copy of r85233, trunk/libs/any/test/any_test_cv_to_rv_failed.cpp)
@@ -0,0 +1,39 @@
+// Unit test for boost::any.
+//
+// See http://www.boost.org for most recent version, including documentation.
+//
+// Copyright Antony Polukhin, 2013.
+//
+// Distributed under the Boost
+// Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt).
+
+#include <cstdlib>
+#include <string>
+#include <utility>
+
+#include "boost/any.hpp"
+#include "../test.hpp"
+#include <boost/move/move.hpp>
+
+#ifdef BOOST_NO_CXX11_RVALUE_REFERENCES
+
+int main()
+{
+ BOOST_STATIC_ASSERT(false);
+ return EXIT_SUCCESS;
+}
+
+#else
+
+
+int main()
+{
+ boost::any const cvalue(10);
+ int i = boost::any_cast<int&&>(cvalue);
+ (void)i;
+ return EXIT_SUCCESS;
+}
+
+#endif
+
Copied: branches/release/libs/any/test/any_test_temporary_to_ref_failed.cpp (from r85233, trunk/libs/any/test/any_test_temporary_to_ref_failed.cpp)
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ branches/release/libs/any/test/any_test_temporary_to_ref_failed.cpp 2013-08-29 07:30:58 EDT (Thu, 29 Aug 2013) (r85511, copy of r85233, trunk/libs/any/test/any_test_temporary_to_ref_failed.cpp)
@@ -0,0 +1,38 @@
+// Unit test for boost::any.
+//
+// See http://www.boost.org for most recent version, including documentation.
+//
+// Copyright Antony Polukhin, 2013.
+//
+// Distributed under the Boost
+// Software License, Version 1.0. (See accompanying file
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt).
+
+#include <cstdlib>
+#include <string>
+#include <utility>
+
+#include "boost/any.hpp"
+#include "../test.hpp"
+#include <boost/move/move.hpp>
+
+#ifdef BOOST_NO_CXX11_RVALUE_REFERENCES
+
+int main()
+{
+ BOOST_STATIC_ASSERT(false);
+ return EXIT_SUCCESS;
+}
+
+#else
+
+
+int main()
+{
+ int i = boost::any_cast<int&>(10);
+ (void)i;
+ return EXIT_SUCCESS;
+}
+
+#endif
+
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk