lightweight_test_test3.cpp 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. //
  2. // Test for lightweight_test.hpp
  3. //
  4. // Copyright (c) 2014, 2018 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.hpp>
  11. #include <boost/core/noncopyable.hpp>
  12. #include <ostream>
  13. // EQ
  14. struct eq1: private boost::noncopyable {};
  15. struct eq2: private boost::noncopyable {};
  16. std::ostream& operator<<( std::ostream& os, eq1 const& )
  17. {
  18. return os << "eq1()";
  19. }
  20. std::ostream& operator<<( std::ostream& os, eq2 const& )
  21. {
  22. return os << "eq2()";
  23. }
  24. bool operator==( eq1 const&, eq2 const& )
  25. {
  26. return true;
  27. }
  28. // NE
  29. struct ne1: private boost::noncopyable {};
  30. struct ne2: private boost::noncopyable {};
  31. std::ostream& operator<<( std::ostream& os, ne1 const& )
  32. {
  33. return os << "ne1()";
  34. }
  35. std::ostream& operator<<( std::ostream& os, ne2 const& )
  36. {
  37. return os << "ne2()";
  38. }
  39. bool operator!=( ne1 const&, ne2 const& )
  40. {
  41. return true;
  42. }
  43. // LT
  44. struct lt1: private boost::noncopyable {};
  45. struct lt2: private boost::noncopyable {};
  46. std::ostream& operator<<( std::ostream& os, lt1 const& )
  47. {
  48. return os << "lt1()";
  49. }
  50. std::ostream& operator<<( std::ostream& os, lt2 const& )
  51. {
  52. return os << "lt2()";
  53. }
  54. bool operator<( lt1 const&, lt2 const& )
  55. {
  56. return true;
  57. }
  58. // LE
  59. struct le1: private boost::noncopyable {};
  60. struct le2: private boost::noncopyable {};
  61. std::ostream& operator<<( std::ostream& os, le1 const& )
  62. {
  63. return os << "le1()";
  64. }
  65. std::ostream& operator<<( std::ostream& os, le2 const& )
  66. {
  67. return os << "le2()";
  68. }
  69. bool operator<=( le1 const&, le2 const& )
  70. {
  71. return true;
  72. }
  73. // GT
  74. struct gt1: private boost::noncopyable {};
  75. struct gt2: private boost::noncopyable {};
  76. std::ostream& operator<<( std::ostream& os, gt1 const& )
  77. {
  78. return os << "gt1()";
  79. }
  80. std::ostream& operator<<( std::ostream& os, gt2 const& )
  81. {
  82. return os << "gt2()";
  83. }
  84. bool operator>( gt1 const&, gt2 const& )
  85. {
  86. return true;
  87. }
  88. // GE
  89. struct ge1: private boost::noncopyable {};
  90. struct ge2: private boost::noncopyable {};
  91. std::ostream& operator<<( std::ostream& os, ge1 const& )
  92. {
  93. return os << "ge1()";
  94. }
  95. std::ostream& operator<<( std::ostream& os, ge2 const& )
  96. {
  97. return os << "ge2()";
  98. }
  99. bool operator>=( ge1 const&, ge2 const& )
  100. {
  101. return true;
  102. }
  103. //
  104. int main()
  105. {
  106. BOOST_TEST_EQ( eq1(), eq2() );
  107. BOOST_TEST_NE( ne1(), ne2() );
  108. BOOST_TEST_LT( lt1(), lt2() );
  109. BOOST_TEST_LE( le1(), le2() );
  110. BOOST_TEST_GT( gt1(), gt2() );
  111. BOOST_TEST_GE( ge1(), ge2() );
  112. return boost::report_errors();
  113. }