kokkos-execution 0.0.1
Loading...
Searching...
No Matches
test_transform_sender.cpp
Go to the documentation of this file.
1#include "gtest/gtest.h"
2
4
7
18
19namespace Tests {
20
29TEST(TransformSender, transform_sender_moves_once) {
30 using counter_t = Tests::Utils::Functors::Counter;
31 using functor_t = std::identity;
32
33 counter_t::reset();
34
35 {
36 [[maybe_unused]]
37 const auto sndr = stdexec::then(
38 stdexec::then(stdexec::then(stdexec::just(counter_t{}), functor_t{}), functor_t{}), functor_t{});
39
40 ASSERT_EQ(counter_t::default_constructions, 1);
41 ASSERT_EQ(counter_t::destructions, 4);
42 ASSERT_EQ(counter_t::copy_constructions, 0);
43 ASSERT_EQ(counter_t::copy_assignments, 0);
44 ASSERT_EQ(counter_t::move_constructions, 4);
45 ASSERT_EQ(counter_t::move_assignments, 0);
46 }
47
48 counter_t::reset();
49
50 [[maybe_unused]]
51 const auto opstate = stdexec::connect(
52 stdexec::then(stdexec::then(stdexec::then(stdexec::just(counter_t{}), functor_t{}), functor_t{}), functor_t{}),
54
55 ASSERT_EQ(counter_t::default_constructions, 1);
56 ASSERT_EQ(counter_t::destructions, 5);
57 ASSERT_EQ(counter_t::copy_constructions, 0);
58 ASSERT_EQ(counter_t::copy_assignments, 0);
59 ASSERT_EQ(counter_t::move_constructions, 5);
60 ASSERT_EQ(counter_t::move_assignments, 0);
61}
62
65 using counter_t = Tests::Utils::Functors::CounterRef;
66
67 counter_t::counters counts{};
68
69 [[maybe_unused]]
70 const auto opstate = stdexec::connect(stdexec::just(counter_t(counts)), Tests::Utils::SinkReceiver{});
71 return counts.constructions == 1 && counts.destructions == 2 && counts.copy_constructions == 0
72 && counts.copy_assignments == 0 && counts.move_constructions == 2 && counts.move_assignments == 0;
73}
74
76
77} // namespace Tests
consteval bool test_transform_sender_moves_once()
Similar to Tests::Utils::Functors::Counter, but the internal counters are not atomic.
Definition counter.hpp:70
Count construction, move/copy construction, move/copy assignment and destruction atomically on host.
Definition counter.hpp:14
A receiver that can handle all completions and does nothing with them.