MCPcopy Create free account
hub / github.com/apache/arrow / TEST

Function TEST

cpp/src/arrow/util/future_test.cc:163–219  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

161// Simple in-thread tests
162
163TEST(FutureSyncTest, Int) {
164 {
165 // MarkFinished(int)
166 auto fut = Future<int>::Make();
167 AssertNotFinished(fut);
168 fut.MarkFinished(42);
169 AssertSuccessful(fut);
170 auto res = fut.result();
171 ASSERT_OK(res);
172 ASSERT_EQ(*res, 42);
173 res = std::move(fut).result();
174 ASSERT_OK(res);
175 ASSERT_EQ(*res, 42);
176 }
177 {
178 // MakeFinished(int)
179 auto fut = Future<int>::MakeFinished(42);
180 AssertSuccessful(fut);
181 auto res = fut.result();
182 ASSERT_OK(res);
183 ASSERT_EQ(*res, 42);
184 res = std::move(fut.result());
185 ASSERT_OK(res);
186 ASSERT_EQ(*res, 42);
187 }
188 {
189 // MarkFinished(Result<int>)
190 auto fut = Future<int>::Make();
191 AssertNotFinished(fut);
192 fut.MarkFinished(Result<int>(43));
193 AssertSuccessful(fut);
194 ASSERT_OK_AND_ASSIGN(auto value, fut.result());
195 ASSERT_EQ(value, 43);
196 }
197 {
198 // MarkFinished(failed Result<int>)
199 auto fut = Future<int>::Make();
200 AssertNotFinished(fut);
201 fut.MarkFinished(Result<int>(Status::IOError("xxx")));
202 AssertFailed(fut);
203 ASSERT_RAISES(IOError, fut.result());
204 }
205 {
206 // MakeFinished(Status)
207 auto fut = Future<int>::MakeFinished(Status::IOError("xxx"));
208 AssertFailed(fut);
209 ASSERT_RAISES(IOError, fut.result());
210 }
211 {
212 // MarkFinished(Status)
213 auto fut = Future<int>::Make();
214 AssertNotFinished(fut);
215 fut.MarkFinished(Status::IOError("xxx"));
216 AssertFailed(fut);
217 ASSERT_RAISES(IOError, fut.result());
218 }
219}
220

Callers

nothing calls this directly

Calls 15

AssertNotFinishedFunction · 0.85
AssertSuccessfulFunction · 0.85
IOErrorFunction · 0.85
AssertFailedFunction · 0.85
SleepABitFunction · 0.85
IsFutureFinishedFunction · 0.85
AssertFinishedFunction · 0.85
AllCompleteFunction · 0.85
BreakFunction · 0.85
ContinueClass · 0.85
LoopFunction · 0.85
FinishesFunction · 0.85

Tested by

no test coverage detected