You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

61 lines
2.8 KiB

  1. #include <cpputils/mp/container/pair.h>
  2. #include <cpputils/mp/operations/compare/equal.h>
  3. #include <cpputils/mp/operations/compare/not_equal.h>
  4. #include <cpputils/mp/operations/compare/less.h>
  5. #include <cpputils/mp/operations/compare/less_equal.h>
  6. #include <cpputils/mp/operations/compare/greater.h>
  7. #include <cpputils/mp/operations/compare/greater_equal.h>
  8. using namespace ::utl::mp;
  9. using namespace ::utl::mp::operators;
  10. namespace test_mp_container_pair
  11. {
  12. constexpr auto my_pair = make_pair(1, 'x');
  13. static_assert(first(my_pair) == 1, "");
  14. static_assert(second(my_pair) == 'x', "");
  15. static_assert(my_pair.first() == 1, "");
  16. static_assert(my_pair.second() == 'x', "");
  17. static_assert(equal(make_pair(1, 'x'), make_pair(1, 'x')), "");
  18. static_assert( make_pair(1, 'x') == make_pair(1, 'x'), "");
  19. static_assert(not_equal(make_pair(1, 'x'), make_pair(2, 'x')), "");
  20. static_assert( make_pair(1, 'x') != make_pair(2, 'x'), "");
  21. static_assert(less(make_pair(1, 'x'), make_pair(1, 'y')), "");
  22. static_assert(less(make_pair(1, 'x'), make_pair(2, 'x')), "");
  23. static_assert(less(make_pair(1, 'x'), make_pair(2, 'a')), "");
  24. static_assert(make_pair(1, 'x') < make_pair(1, 'y'), "");
  25. static_assert(make_pair(1, 'x') < make_pair(2, 'x'), "");
  26. static_assert(make_pair(1, 'x') < make_pair(2, 'a'), "");
  27. static_assert(less_equal(make_pair(1, 'x'), make_pair(1, 'x')), "");
  28. static_assert(less_equal(make_pair(1, 'x'), make_pair(1, 'y')), "");
  29. static_assert(less_equal(make_pair(1, 'x'), make_pair(2, 'x')), "");
  30. static_assert(less_equal(make_pair(1, 'x'), make_pair(2, 'a')), "");
  31. static_assert(make_pair(1, 'x') <= make_pair(1, 'x'), "");
  32. static_assert(make_pair(1, 'x') <= make_pair(1, 'y'), "");
  33. static_assert(make_pair(1, 'x') <= make_pair(2, 'x'), "");
  34. static_assert(make_pair(1, 'x') <= make_pair(2, 'a'), "");
  35. static_assert(greater(make_pair(1, 'y'), make_pair(1, 'x')), "");
  36. static_assert(greater(make_pair(2, 'x'), make_pair(1, 'x')), "");
  37. static_assert(greater(make_pair(2, 'a'), make_pair(1, 'x')), "");
  38. static_assert(make_pair(1, 'y') > make_pair(1, 'x'), "");
  39. static_assert(make_pair(2, 'x') > make_pair(1, 'x'), "");
  40. static_assert(make_pair(2, 'a') > make_pair(1, 'x'), "");
  41. static_assert(greater_equal(make_pair(1, 'x'), make_pair(1, 'x')), "");
  42. static_assert(greater_equal(make_pair(1, 'y'), make_pair(1, 'x')), "");
  43. static_assert(greater_equal(make_pair(2, 'x'), make_pair(1, 'x')), "");
  44. static_assert(greater_equal(make_pair(2, 'a'), make_pair(1, 'x')), "");
  45. static_assert(make_pair(1, 'x') >= make_pair(1, 'x'), "");
  46. static_assert(make_pair(1, 'y') >= make_pair(1, 'x'), "");
  47. static_assert(make_pair(2, 'x') >= make_pair(1, 'x'), "");
  48. static_assert(make_pair(2, 'a') >= make_pair(1, 'x'), "");
  49. }