make_local_shared_array_value_test.cpp 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. Copyright 2017 Glen Joseph Fernandes
  3. (glenjofe@gmail.com)
  4. Distributed under the Boost Software License, Version 1.0.
  5. (http://www.boost.org/LICENSE_1_0.txt)
  6. */
  7. #include <boost/config.hpp>
  8. #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && \
  9. !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
  10. #include <boost/detail/lightweight_test.hpp>
  11. #include <boost/smart_ptr/make_local_shared.hpp>
  12. int main()
  13. {
  14. {
  15. boost::local_shared_ptr<int[]> result =
  16. boost::make_local_shared<int[]>(4, 1);
  17. BOOST_TEST(result[0] == 1);
  18. BOOST_TEST(result[1] == 1);
  19. BOOST_TEST(result[2] == 1);
  20. BOOST_TEST(result[3] == 1);
  21. }
  22. {
  23. boost::local_shared_ptr<int[4]> result =
  24. boost::make_local_shared<int[4]>(1);
  25. BOOST_TEST(result[0] == 1);
  26. BOOST_TEST(result[1] == 1);
  27. BOOST_TEST(result[2] == 1);
  28. BOOST_TEST(result[3] == 1);
  29. }
  30. {
  31. boost::local_shared_ptr<const int[]> result =
  32. boost::make_local_shared<const int[]>(4, 1);
  33. BOOST_TEST(result[0] == 1);
  34. BOOST_TEST(result[1] == 1);
  35. BOOST_TEST(result[2] == 1);
  36. BOOST_TEST(result[3] == 1);
  37. }
  38. {
  39. boost::local_shared_ptr<const int[4]> result =
  40. boost::make_local_shared<const int[4]>(1);
  41. BOOST_TEST(result[0] == 1);
  42. BOOST_TEST(result[1] == 1);
  43. BOOST_TEST(result[2] == 1);
  44. BOOST_TEST(result[3] == 1);
  45. }
  46. return boost::report_errors();
  47. }
  48. #else
  49. int main()
  50. {
  51. return 0;
  52. }
  53. #endif