eq.pass.cpp 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. //===----------------------------------------------------------------------===//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. // <tuple>
  9. // template <class... Types> class tuple;
  10. // template<class... TTypes, class... UTypes>
  11. // bool
  12. // operator==(const tuple<TTypes...>& t, const tuple<UTypes...>& u);
  13. // UNSUPPORTED: c++98, c++03
  14. #include <tuple>
  15. #include <string>
  16. #include <cassert>
  17. #include "test_macros.h"
  18. int main(int, char**)
  19. {
  20. {
  21. typedef std::tuple<> T1;
  22. typedef std::tuple<> T2;
  23. const T1 t1;
  24. const T2 t2;
  25. assert(t1 == t2);
  26. assert(!(t1 != t2));
  27. }
  28. {
  29. typedef std::tuple<int> T1;
  30. typedef std::tuple<double> T2;
  31. const T1 t1(1);
  32. const T2 t2(1.1);
  33. assert(!(t1 == t2));
  34. assert(t1 != t2);
  35. }
  36. {
  37. typedef std::tuple<int> T1;
  38. typedef std::tuple<double> T2;
  39. const T1 t1(1);
  40. const T2 t2(1);
  41. assert(t1 == t2);
  42. assert(!(t1 != t2));
  43. }
  44. {
  45. typedef std::tuple<int, double> T1;
  46. typedef std::tuple<double, long> T2;
  47. const T1 t1(1, 2);
  48. const T2 t2(1, 2);
  49. assert(t1 == t2);
  50. assert(!(t1 != t2));
  51. }
  52. {
  53. typedef std::tuple<int, double> T1;
  54. typedef std::tuple<double, long> T2;
  55. const T1 t1(1, 2);
  56. const T2 t2(1, 3);
  57. assert(!(t1 == t2));
  58. assert(t1 != t2);
  59. }
  60. {
  61. typedef std::tuple<int, double> T1;
  62. typedef std::tuple<double, long> T2;
  63. const T1 t1(1, 2);
  64. const T2 t2(1.1, 2);
  65. assert(!(t1 == t2));
  66. assert(t1 != t2);
  67. }
  68. {
  69. typedef std::tuple<int, double> T1;
  70. typedef std::tuple<double, long> T2;
  71. const T1 t1(1, 2);
  72. const T2 t2(1.1, 3);
  73. assert(!(t1 == t2));
  74. assert(t1 != t2);
  75. }
  76. {
  77. typedef std::tuple<long, int, double> T1;
  78. typedef std::tuple<double, long, int> T2;
  79. const T1 t1(1, 2, 3);
  80. const T2 t2(1, 2, 3);
  81. assert(t1 == t2);
  82. assert(!(t1 != t2));
  83. }
  84. {
  85. typedef std::tuple<long, int, double> T1;
  86. typedef std::tuple<double, long, int> T2;
  87. const T1 t1(1, 2, 3);
  88. const T2 t2(1.1, 2, 3);
  89. assert(!(t1 == t2));
  90. assert(t1 != t2);
  91. }
  92. {
  93. typedef std::tuple<long, int, double> T1;
  94. typedef std::tuple<double, long, int> T2;
  95. const T1 t1(1, 2, 3);
  96. const T2 t2(1, 3, 3);
  97. assert(!(t1 == t2));
  98. assert(t1 != t2);
  99. }
  100. {
  101. typedef std::tuple<long, int, double> T1;
  102. typedef std::tuple<double, long, int> T2;
  103. const T1 t1(1, 2, 3);
  104. const T2 t2(1, 2, 4);
  105. assert(!(t1 == t2));
  106. assert(t1 != t2);
  107. }
  108. {
  109. typedef std::tuple<long, int, double> T1;
  110. typedef std::tuple<double, long, int> T2;
  111. const T1 t1(1, 2, 3);
  112. const T2 t2(1, 3, 2);
  113. assert(!(t1 == t2));
  114. assert(t1 != t2);
  115. }
  116. {
  117. typedef std::tuple<long, int, double> T1;
  118. typedef std::tuple<double, long, int> T2;
  119. const T1 t1(1, 2, 3);
  120. const T2 t2(1.1, 2, 2);
  121. assert(!(t1 == t2));
  122. assert(t1 != t2);
  123. }
  124. {
  125. typedef std::tuple<long, int, double> T1;
  126. typedef std::tuple<double, long, int> T2;
  127. const T1 t1(1, 2, 3);
  128. const T2 t2(1.1, 3, 3);
  129. assert(!(t1 == t2));
  130. assert(t1 != t2);
  131. }
  132. {
  133. typedef std::tuple<long, int, double> T1;
  134. typedef std::tuple<double, long, int> T2;
  135. const T1 t1(1, 2, 3);
  136. const T2 t2(1.1, 3, 2);
  137. assert(!(t1 == t2));
  138. assert(t1 != t2);
  139. }
  140. #if TEST_STD_VER > 11
  141. {
  142. typedef std::tuple<long, int, double> T1;
  143. typedef std::tuple<double, long, int> T2;
  144. constexpr T1 t1(1, 2, 3);
  145. constexpr T2 t2(1.1, 3, 2);
  146. static_assert(!(t1 == t2), "");
  147. static_assert(t1 != t2, "");
  148. }
  149. #endif
  150. return 0;
  151. }