From d5c32367b14f92edaa7b382477a04122f86f7a32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Hunold?= Date: Fri, 7 Apr 2017 09:45:10 +0200 Subject: [PATCH] Enh: test brace initialisation with values for https://svn.boost.org/trac/boost/ticket/12788 --- test/Jamfile.v2 | 1 + test/optional_test_braces.cpp | 51 +++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 test/optional_test_braces.cpp diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 1820ba45..45c35243 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -18,6 +18,7 @@ import testing ; { test-suite optional : [ run optional_test.cpp ] + [ run optional_test_braces.cpp ] [ run optional_test_swap.cpp ] [ run optional_test_conversions_from_U.cpp ] [ run optional_test_convert_from_T.cpp ] diff --git a/test/optional_test_braces.cpp b/test/optional_test_braces.cpp new file mode 100644 index 00000000..b9d14a7d --- /dev/null +++ b/test/optional_test_braces.cpp @@ -0,0 +1,51 @@ +// Copyright (C) 2016 Jürgen Hunold +// +// Use, modification, and distribution is 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) +// +// See http://www.boost.org/lib/optional for documentation. + + +#include "boost/optional/optional.hpp" + +#include + +#include "boost/core/lightweight_test.hpp" + +using boost::optional; + + +struct Init +{ + Init(int,double); +}; + +#ifndef BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX + + +template +void test_brace_init() +{ + optional o = {1, 1.1}; + BOOST_TEST(o); +} + +template +void test_brace_assign() +{ + optional o; + o = {1, 1.1}; + BOOST_TEST(o); +} +#endif + +int main() +{ +#ifndef BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX + test_brace_init(); + test_brace_assign(); +#endif + + return boost::report_errors(); +}