experimental optional config test

This commit is contained in:
Andrzej Krzemienski
2015-10-08 18:53:28 +02:00
parent 238dd15ed0
commit 0d5061aebe
6 changed files with 173 additions and 0 deletions

View File

@ -52,4 +52,11 @@
# define BOOST_OPTIONAL_DETAIL_USE_ATTRIBUTE_MAY_ALIAS
#endif
#if (defined(_MSC_VER) && _MSC_VER <= 1800)
// on MSCV 2013 and earlier an unwanted temporary is created when you assign from
// a const lvalue of integral type. Thus we bind not to the original address but
// to a temporary.
# define BOOST_OPTIONAL_CONFIG_NO_PROPER_ASSIGN_FROM_CONST_INT
#endif
#endif // header guard

View File

@ -60,5 +60,7 @@ import testing ;
[ compile-fail optional_test_fail_io_without_io.cpp ]
[ compile-fail optional_test_fail_none_io_without_io.cpp ]
[ compile-fail optional_test_fail_convert_assign_of_enums.cpp ]
[ run optional_xconfig_NO_PROPER_ASSIGN_FROM_CONST_INT_pass.cpp ]
[ run-fail optional_xconfig_NO_PROPER_ASSIGN_FROM_CONST_INT_fail.cpp ]
;
}

View File

@ -0,0 +1,42 @@
// Copyright (C) 2015 Andrzej Krzemienski.
//
// 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.
//
// You are welcome to contact the author at:
// akrzemi1@gmail.com
#include "boost/core/lightweight_test.hpp"
#include "boost/optional/detail/optional_config.hpp"
#ifndef BOOST_OPTIONAL_CONFIG_NO_PROPER_ASSIGN_FROM_CONST_INT
int main()
{
BOOST_ERROR("failed as requested");
return boost::report_errors();
}
#else
const int global_i = 0;
struct Binder
{
void operator=(const int& i)
{
BOOST_TEST(&i == &global_i);
}
};
int main()
{
Binder s;
s = global_i;
return boost::report_errors();
}
#endif

View File

@ -0,0 +1,41 @@
// Copyright (C) 2015 Andrzej Krzemienski.
//
// 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.
//
// You are welcome to contact the author at:
// akrzemi1@gmail.com
#include "boost/core/lightweight_test.hpp"
#include "boost/optional/detail/optional_config.hpp"
#ifndef BOOST_OPTIONAL_CONFIG_NO_PROPER_ASSIGN_FROM_CONST_INT
const int global_i = 0;
struct Binder
{
void operator=(const int& i)
{
BOOST_TEST(&i == &global_i);
}
};
int main()
{
Binder s;
s = global_i;
return boost::report_errors();
}
#else
int main()
{
return boost::report_errors();
}
#endif

View File

@ -0,0 +1,41 @@
// Copyright (C) 2015 Andrzej Krzemienski.
//
// 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.
//
// You are welcome to contact the author at:
// akrzemi1@gmail.com
#include "boost/core/lightweight_test.hpp"
#include "boost/optional/detail/optional_config.hpp"
#ifndef BOOST_OPTIONAL_CONFIG_NO_PROPER_ASSIGN_FROM_CONST_INT
int main()
{
BOOST_ERROR("failed as requested");
return boost::report_errors();
}
#else
const int global_i = 0;
struct Binder
{
Binder(const int& i)
{
BOOST_TEST(&i == &global_i);
}
};
int main()
{
Binder b = global_i;
return boost::report_errors();
}
#endif

View File

@ -0,0 +1,40 @@
// Copyright (C) 2015 Andrzej Krzemienski.
//
// 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.
//
// You are welcome to contact the author at:
// akrzemi1@gmail.com
#include "boost/core/lightweight_test.hpp"
#include "boost/optional/detail/optional_config.hpp"
#ifndef BOOST_OPTIONAL_CONFIG_NO_PROPER_ASSIGN_FROM_CONST_INT
const int global_i = 0;
struct Binder
{
Binder(const int& i)
{
BOOST_TEST(&i == &global_i);
}
};
int main()
{
Binder b = global_i;
return boost::report_errors();
}
#else
int main()
{
return boost::report_errors();
}
#endif