make_shared_arrays_test.cpp 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /*
  2. Copyright 2012-2015 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_UNIFIED_INITIALIZATION_SYNTAX)
  9. #include <boost/core/lightweight_test.hpp>
  10. #include <boost/smart_ptr/make_shared.hpp>
  11. int main()
  12. {
  13. {
  14. boost::shared_ptr<int[][2]> result =
  15. boost::make_shared<int[][2]>(2, {0, 1});
  16. BOOST_TEST(result[0][0] == 0);
  17. BOOST_TEST(result[0][1] == 1);
  18. BOOST_TEST(result[1][0] == 0);
  19. BOOST_TEST(result[1][1] == 1);
  20. }
  21. {
  22. boost::shared_ptr<int[2][2]> result =
  23. boost::make_shared<int[2][2]>({0, 1});
  24. BOOST_TEST(result[0][0] == 0);
  25. BOOST_TEST(result[0][1] == 1);
  26. BOOST_TEST(result[1][0] == 0);
  27. BOOST_TEST(result[1][1] == 1);
  28. }
  29. {
  30. boost::shared_ptr<const int[][2]> result =
  31. boost::make_shared<const int[][2]>(2, {0, 1});
  32. BOOST_TEST(result[0][0] == 0);
  33. BOOST_TEST(result[0][1] == 1);
  34. BOOST_TEST(result[1][0] == 0);
  35. BOOST_TEST(result[1][1] == 1);
  36. }
  37. {
  38. boost::shared_ptr<const int[2][2]> result =
  39. boost::make_shared<const int[2][2]>({0, 1});
  40. BOOST_TEST(result[0][0] == 0);
  41. BOOST_TEST(result[0][1] == 1);
  42. BOOST_TEST(result[1][0] == 0);
  43. BOOST_TEST(result[1][1] == 1);
  44. }
  45. return boost::report_errors();
  46. }
  47. #else
  48. int main()
  49. {
  50. return 0;
  51. }
  52. #endif