Squashed 'third_party/boostorg/functional/' content from commit 7516442
Change-Id: I0e437294bc2af9d32de5022be6ac788cc67244d1
git-subtree-dir: third_party/boostorg/functional
git-subtree-split: 7516442815900430cc9c4a6190354e11bcbe72dd
diff --git a/factory/test/factory.cpp b/factory/test/factory.cpp
new file mode 100644
index 0000000..ef895cf
--- /dev/null
+++ b/factory/test/factory.cpp
@@ -0,0 +1,53 @@
+/*=============================================================================
+ Copyright (c) 2007 Tobias Schwinger
+
+ Use modification and distribution are subject to 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 <boost/functional/factory.hpp>
+#include <boost/core/lightweight_test.hpp>
+
+#include <memory>
+
+class sum
+{
+ int val_sum;
+ public:
+ sum(int a, int b) : val_sum(a + b) { }
+
+ operator int() const { return this->val_sum; }
+};
+
+// Suppress warnings about std::auto_ptr.
+#if defined(__clang__)
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+#endif
+
+int main()
+{
+ int one = 1, two = 2;
+ {
+ sum* instance( boost::factory< sum* >()(one,two) );
+ BOOST_TEST(*instance == 3);
+ }
+#if !defined(BOOST_NO_AUTO_PTR)
+ {
+ std::auto_ptr<sum> instance( boost::factory< std::auto_ptr<sum> >()(one,two) );
+ BOOST_TEST(*instance == 3);
+ }
+#endif
+#if !defined(BOOST_NO_CXX11_SMART_PTR)
+ {
+ std::unique_ptr<sum> instance( boost::factory< std::unique_ptr<sum> >()(one,two) );
+ BOOST_TEST(*instance == 3);
+ }
+#endif
+ return boost::report_errors();
+}
+
+#if defined(__clang__)
+#pragma clang diagnostic pop
+#endif