Skip to content

Commit

Permalink
minimal fix
Browse files Browse the repository at this point in the history
  • Loading branch information
SachiSakurane committed Feb 20, 2025
1 parent 7830268 commit 6312a1c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
2 changes: 0 additions & 2 deletions include/riw/notify/subsctiption.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#pragma once

#include <concepts>

namespace riw {
template <class Type>
class subscription {
Expand Down
26 changes: 24 additions & 2 deletions test/notify/connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,32 @@ TEST(Notify_ConnectionTest, Notify) {
auto o = i | [](auto i) { return std::to_string(i); };

testing::internal::CaptureStdout();

auto s = o | [](auto s) { std::cout << "string: " << s << std::endl; };

std::string log = testing::internal::GetCapturedStdout();

ASSERT_EQ(static_cast<std::string>(log), "string: 42\n"s);
}

TEST(Notify_ConnectionTest, Unsbscribe) {
riw::behavior<int> i{42};

ASSERT_EQ(i, 42);
auto o = i | [](auto i) { return std::to_string(i); };

{
auto s = o | [](auto s) { std::cout << "bar" << s << std::endl; };
ASSERT_EQ(o.subscriptions_count(), 1);
}

ASSERT_EQ(o.subscriptions_count(), 0);

auto s = o | [](auto s) { std::cout << "foo" << s << std::endl; };

ASSERT_EQ(o.subscriptions_count(), 1);

testing::internal::CaptureStdout();
i = 99;
std::string log = testing::internal::GetCapturedStdout();

ASSERT_EQ(static_cast<std::string>(log), "foo99\n"s);
}

0 comments on commit 6312a1c

Please sign in to comment.