19 #include <gtest/gtest.h> 37 TEST(RxTest, ObserveInline) {
59 TEST(RxTest, SubscriptionMove) {
71 TEST(RxTest, SubscriptionOutlivesSubject) {
80 TEST(RxTest, SubscribeDuringCallback) {
84 int outerCount = 0, innerCount = 0;
91 subject.
onNext(0xDEADBEEF);
96 TEST(RxTest, ObserveDuringCallback) {
98 int outerCount = 0, innerCount = 0;
104 subject.
onNext(0xDEADBEEF);
109 TEST(RxTest, ObserveInlineDuringCallback) {
111 int outerCount = 0, innerCount = 0;
119 subject.
onNext(0xDEADBEEF);
126 TEST(RxTest, UnsubscribeDuringCallback) {
130 int count1 = 0, count2 = 0;
142 TEST(RxTest, SubscribeUnsubscribeDuringCallback) {
146 int outerCount = 0, innerCount = 0;
158 typedef std::unique_ptr<int>
MO;
159 static MO makeMO() {
return std::make_unique<int>(1); }
160 template <
typename T>
169 auto s1 = subject.
subscribe(makeMOObserver<MO>());
170 auto s2 = subject.
subscribe(makeMOObserver<MO>());
181 CO(
const CO&) =
default;
185 template <
typename T>
192 auto s1 = subject.
subscribe(makeCOObserver<CO>());
virtual void observe(ObserverPtr< T > observer)
std::shared_ptr< Observer< T >> ObserverPtr
TEST(Wangle, ClientServerTest)
virtual Subscription< T > subscribe(ObserverPtr< T > observer)
#define EXPECT_EQ(val1, val2)
constexpr detail::Map< Move > move
static ObserverPtr< T > makeCOObserver()
std::unique_ptr< int > MO
static std::unique_ptr< Observer< int > > incrementer(int &counter)
void onNext(const T &val) override
static ObserverPtr< T > makeMOObserver()
std::atomic< int > counter
static std::unique_ptr< Observer > create(N &&onNextFn, E &&onErrorFn, C &&onCompletedFn)