8 #include <throwing/shared_ptr.hpp> 10 TEST_CASE(
"comparison operators between valid throwing::shared_ptr",
11 "[shared_ptr][comparison]") {
14 auto t_ptr1 = throwing::shared_ptr<
int>(ptr1);
15 auto t_ptr1_1 = t_ptr1;
16 auto t_ptr2 = throwing::shared_ptr<
int>(ptr2);
18 REQUIRE_FALSE(t_ptr1 == t_ptr2);
19 REQUIRE_FALSE(t_ptr1_1 == t_ptr2);
20 REQUIRE(t_ptr1 == t_ptr1);
21 REQUIRE(t_ptr1 == t_ptr1_1);
23 REQUIRE(t_ptr1 != t_ptr2);
24 REQUIRE(t_ptr1_1 != t_ptr2);
25 REQUIRE_FALSE(t_ptr1 != t_ptr1);
26 REQUIRE_FALSE(t_ptr1 != t_ptr1_1);
28 REQUIRE((t_ptr1 < t_ptr2) == (ptr1 < ptr2));
29 REQUIRE((t_ptr1_1 < t_ptr2) == (ptr1 < ptr2));
30 REQUIRE_FALSE(t_ptr1 < t_ptr1);
31 REQUIRE_FALSE(t_ptr1 < t_ptr1_1);
33 REQUIRE((t_ptr1 > t_ptr2) == (ptr1 > ptr2));
34 REQUIRE((t_ptr1_1 > t_ptr2) == (ptr1 > ptr2));
35 REQUIRE_FALSE(t_ptr1 > t_ptr1);
36 REQUIRE_FALSE(t_ptr1 > t_ptr1_1);
38 REQUIRE((t_ptr1 <= t_ptr2) == (ptr1 <= ptr2));
39 REQUIRE((t_ptr1_1 <= t_ptr2) == (ptr1 <= ptr2));
40 REQUIRE((t_ptr1 <= t_ptr1) == (ptr1 <= ptr1));
41 REQUIRE((t_ptr1 <= t_ptr1_1) == (ptr1 <= ptr1));
43 REQUIRE((t_ptr1 >= t_ptr2) == (ptr1 >= ptr2));
44 REQUIRE((t_ptr1_1 >= t_ptr2) == (ptr1 >= ptr2));
45 REQUIRE((t_ptr1 >= t_ptr1) == (ptr1 >= ptr1));
46 REQUIRE((t_ptr1 >= t_ptr1_1) == (ptr1 >= ptr1));
49 TEST_CASE(
"comparison operators between valid throwing::shared_ptr and " 51 "[shared_ptr][comparison]") {
54 auto t_ptr1 = throwing::shared_ptr<
int>(ptr1);
55 auto t_ptr1_1 = t_ptr1;
56 auto t_ptr2 = std::shared_ptr<
int>(ptr2);
58 REQUIRE_FALSE(t_ptr1 == t_ptr2);
59 REQUIRE_FALSE(t_ptr1_1 == t_ptr2);
60 REQUIRE(t_ptr1 == t_ptr1);
61 REQUIRE(t_ptr1 == t_ptr1_1);
63 REQUIRE(t_ptr1 != t_ptr2);
64 REQUIRE(t_ptr1_1 != t_ptr2);
65 REQUIRE_FALSE(t_ptr1 != t_ptr1);
66 REQUIRE_FALSE(t_ptr1 != t_ptr1_1);
68 REQUIRE((t_ptr1 < t_ptr2) == (ptr1 < ptr2));
69 REQUIRE((t_ptr1_1 < t_ptr2) == (ptr1 < ptr2));
70 REQUIRE_FALSE(t_ptr1 < t_ptr1);
71 REQUIRE_FALSE(t_ptr1 < t_ptr1_1);
73 REQUIRE((t_ptr1 > t_ptr2) == (ptr1 > ptr2));
74 REQUIRE((t_ptr1_1 > t_ptr2) == (ptr1 > ptr2));
75 REQUIRE_FALSE(t_ptr1 > t_ptr1);
76 REQUIRE_FALSE(t_ptr1 > t_ptr1_1);
78 REQUIRE((t_ptr1 <= t_ptr2) == (ptr1 <= ptr2));
79 REQUIRE((t_ptr1_1 <= t_ptr2) == (ptr1 <= ptr2));
80 REQUIRE((t_ptr1 <= t_ptr1) == (ptr1 <= ptr1));
81 REQUIRE((t_ptr1 <= t_ptr1_1) == (ptr1 <= ptr1));
83 REQUIRE((t_ptr1 >= t_ptr2) == (ptr1 >= ptr2));
84 REQUIRE((t_ptr1_1 >= t_ptr2) == (ptr1 >= ptr2));
85 REQUIRE((t_ptr1 >= t_ptr1) == (ptr1 >= ptr1));
86 REQUIRE((t_ptr1 >= t_ptr1_1) == (ptr1 >= ptr1));
89 TEST_CASE(
"comparison operators between valid throwing::shared_ptr and " 90 "std::shared_ptr (other side)",
91 "[shared_ptr][comparison]") {
94 auto t_ptr1 = std::shared_ptr<
int>(ptr1);
95 auto t_ptr1_1 = t_ptr1;
96 auto t_ptr2 = throwing::shared_ptr<
int>(ptr2);
98 REQUIRE_FALSE(t_ptr1 == t_ptr2);
99 REQUIRE_FALSE(t_ptr1_1 == t_ptr2);
100 REQUIRE(t_ptr1 == t_ptr1);
101 REQUIRE(t_ptr1 == t_ptr1_1);
103 REQUIRE(t_ptr1 != t_ptr2);
104 REQUIRE(t_ptr1_1 != t_ptr2);
105 REQUIRE_FALSE(t_ptr1 != t_ptr1);
106 REQUIRE_FALSE(t_ptr1 != t_ptr1_1);
108 REQUIRE((t_ptr1 < t_ptr2) == (ptr1 < ptr2));
109 REQUIRE((t_ptr1_1 < t_ptr2) == (ptr1 < ptr2));
110 REQUIRE_FALSE(t_ptr1 < t_ptr1);
111 REQUIRE_FALSE(t_ptr1 < t_ptr1_1);
113 REQUIRE((t_ptr1 > t_ptr2) == (ptr1 > ptr2));
114 REQUIRE((t_ptr1_1 > t_ptr2) == (ptr1 > ptr2));
115 REQUIRE_FALSE(t_ptr1 > t_ptr1);
116 REQUIRE_FALSE(t_ptr1 > t_ptr1_1);
118 REQUIRE((t_ptr1 <= t_ptr2) == (ptr1 <= ptr2));
119 REQUIRE((t_ptr1_1 <= t_ptr2) == (ptr1 <= ptr2));
120 REQUIRE((t_ptr1 <= t_ptr1) == (ptr1 <= ptr1));
121 REQUIRE((t_ptr1 <= t_ptr1_1) == (ptr1 <= ptr1));
123 REQUIRE((t_ptr1 >= t_ptr2) == (ptr1 >= ptr2));
124 REQUIRE((t_ptr1_1 >= t_ptr2) == (ptr1 >= ptr2));
125 REQUIRE((t_ptr1 >= t_ptr1) == (ptr1 >= ptr1));
126 REQUIRE((t_ptr1 >= t_ptr1_1) == (ptr1 >= ptr1));
129 TEST_CASE(
"comparison operators with null throwing::shared_ptr",
130 "[shared_ptr][comparison]") {
132 auto t_ptr = throwing::shared_ptr<
int>(ptr);
133 auto empty_t_ptr = throwing::shared_ptr<
int>();
135 REQUIRE(empty_t_ptr ==
nullptr);
136 REQUIRE_FALSE(t_ptr ==
nullptr);
137 REQUIRE(
nullptr == empty_t_ptr);
138 REQUIRE_FALSE(
nullptr == t_ptr);
140 REQUIRE_FALSE(empty_t_ptr !=
nullptr);
141 REQUIRE(t_ptr !=
nullptr);
142 REQUIRE_FALSE(
nullptr != empty_t_ptr);
143 REQUIRE(
nullptr != t_ptr);
145 REQUIRE((t_ptr <
nullptr) == std::less<
int *>()(ptr,
nullptr));
146 REQUIRE((empty_t_ptr <
nullptr) == std::less<
int *>()(
nullptr,
nullptr));
147 REQUIRE((
nullptr < t_ptr) == std::less<
int *>()(
nullptr, ptr));
148 REQUIRE((
nullptr < empty_t_ptr) == std::less<
int *>()(
nullptr,
nullptr));
150 REQUIRE((t_ptr >
nullptr) == std::less<
int *>()(
nullptr, ptr));
151 REQUIRE((empty_t_ptr >
nullptr) == std::less<
int *>()(
nullptr,
nullptr));
152 REQUIRE((
nullptr > t_ptr) == std::less<
int *>()(ptr,
nullptr));
153 REQUIRE((
nullptr > empty_t_ptr) == std::less<
int *>()(
nullptr,
nullptr));
155 REQUIRE((t_ptr <=
nullptr) == !std::less<
int *>()(
nullptr, ptr));
156 REQUIRE((empty_t_ptr <=
nullptr) == !std::less<
int *>()(
nullptr,
nullptr));
157 REQUIRE((
nullptr <= t_ptr) == !std::less<
int *>()(ptr,
nullptr));
158 REQUIRE((
nullptr <= empty_t_ptr) == !std::less<
int *>()(
nullptr,
nullptr));
160 REQUIRE((t_ptr >=
nullptr) == !std::less<
int *>()(ptr,
nullptr));
161 REQUIRE((empty_t_ptr >=
nullptr) == !std::less<
int *>()(
nullptr,
nullptr));
162 REQUIRE((
nullptr >= t_ptr) == !std::less<
int *>()(
nullptr, ptr));
163 REQUIRE((
nullptr >= empty_t_ptr) == !std::less<
int *>()(
nullptr,
nullptr));
TEST_CASE("unique_ptr to array reset to convertible", "[unique_ptr][array][reset][conv.qual]")