Spaces:
Runtime error
Runtime error
File size: 2,255 Bytes
be11144 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
#pragma once
#include <thrust/detail/config.h>
#include <thrust/detail/cpp11_required.h>
#if THRUST_CPP_DIALECT >= 2011
#include <unittest/unittest.h>
#include <thrust/future.h>
#define TEST_EVENT_WAIT(e) \
::unittest::test_event_wait(e, __FILE__, __LINE__) \
/**/
#define TEST_FUTURE_VALUE_RETRIEVAL(f) \
::unittest::test_future_value_retrieval(f, __FILE__, __LINE__) \
/**/
namespace unittest
{
template <typename Event>
__host__
void test_event_wait(
Event&& e, std::string const& filename = "unknown", int lineno = -1
)
{
ASSERT_EQUAL_WITH_FILE_AND_LINE(true, e.valid_stream(), filename, lineno);
e.wait();
e.wait();
ASSERT_EQUAL_WITH_FILE_AND_LINE(true, e.valid_stream(), filename, lineno);
ASSERT_EQUAL_WITH_FILE_AND_LINE(true, e.ready(), filename, lineno);
}
template <typename Future>
__host__
auto test_future_value_retrieval(
Future&& f, std::string const& filename = "unknown", int lineno = -1
) -> decltype(f.extract())
{
ASSERT_EQUAL_WITH_FILE_AND_LINE(true, f.valid_stream(), filename, lineno);
ASSERT_EQUAL_WITH_FILE_AND_LINE(true, f.valid_content(), filename, lineno);
auto const r0 = f.get();
auto const r1 = f.get();
ASSERT_EQUAL_WITH_FILE_AND_LINE(true, f.ready(), filename, lineno);
ASSERT_EQUAL_WITH_FILE_AND_LINE(true, f.valid_stream(), filename, lineno);
ASSERT_EQUAL_WITH_FILE_AND_LINE(true, f.valid_content(), filename, lineno);
ASSERT_EQUAL_WITH_FILE_AND_LINE(r0, r1, filename, lineno);
auto const r2 = f.extract();
ASSERT_THROWS_EQUAL_WITH_FILE_AND_LINE(
auto x = f.extract();
THRUST_UNUSED_VAR(x)
, thrust::event_error
, thrust::event_error(thrust::event_errc::no_content)
, filename, lineno
);
ASSERT_EQUAL_WITH_FILE_AND_LINE(false, f.ready(), filename, lineno);
ASSERT_EQUAL_WITH_FILE_AND_LINE(false, f.valid_stream(), filename, lineno);
ASSERT_EQUAL_WITH_FILE_AND_LINE(false, f.valid_content(), filename, lineno);
ASSERT_EQUAL_WITH_FILE_AND_LINE(r2, r1, filename, lineno);
ASSERT_EQUAL_WITH_FILE_AND_LINE(r2, r0, filename, lineno);
return r2;
}
} // namespace unittest
#endif // THRUST_CPP_DIALECT >= 2011
|