lightweight_test_fail12.cpp 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. //
  2. // Negative test for BOOST_TEST_TRAIT_SAME
  3. //
  4. // Copyright 2014, 2019 Peter Dimov
  5. //
  6. // Distributed under the Boost Software License, Version 1.0.
  7. // See accompanying file LICENSE_1_0.txt or copy at
  8. // http://www.boost.org/LICENSE_1_0.txt
  9. //
  10. #include <boost/core/lightweight_test_trait.hpp>
  11. #include <boost/config.hpp>
  12. struct X
  13. {
  14. typedef int type;
  15. };
  16. template<class T1, class T2> struct Y
  17. {
  18. typedef T1 type;
  19. };
  20. typedef int I1;
  21. typedef const int I2;
  22. typedef volatile int I3;
  23. typedef const volatile int I4;
  24. typedef int& I5;
  25. typedef const int& I6;
  26. typedef volatile int& I7;
  27. typedef const volatile int& I8;
  28. #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
  29. typedef int&& I9;
  30. typedef const int&& I10;
  31. typedef volatile int&& I11;
  32. typedef const volatile int&& I12;
  33. #endif
  34. int main()
  35. {
  36. BOOST_TEST_TRAIT_SAME(char[1], char[2]);
  37. BOOST_TEST_TRAIT_SAME(char[1], char[]);
  38. BOOST_TEST_TRAIT_SAME(char[1], char*);
  39. BOOST_TEST_TRAIT_SAME(void(), void(int));
  40. BOOST_TEST_TRAIT_SAME(void(), void(*)());
  41. BOOST_TEST_TRAIT_SAME(X, void);
  42. BOOST_TEST_TRAIT_SAME(X::type, void);
  43. BOOST_TEST_TRAIT_SAME(X, Y<void, void>);
  44. BOOST_TEST_TRAIT_SAME(X::type, Y<float, int>::type);
  45. BOOST_TEST_TRAIT_SAME(Y<int, float>, Y<int, double>);
  46. BOOST_TEST_TRAIT_SAME(I1, I2);
  47. BOOST_TEST_TRAIT_SAME(I3, I4);
  48. BOOST_TEST_TRAIT_SAME(I5, I6);
  49. BOOST_TEST_TRAIT_SAME(I7, I8);
  50. int expected = 14;
  51. #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
  52. BOOST_TEST_TRAIT_SAME(I9, I10);
  53. BOOST_TEST_TRAIT_SAME(I11, I12);
  54. expected += 2;
  55. #endif
  56. return boost::report_errors() == expected;
  57. }