Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite SimpleUnbufferedChannelTest in channel_test.cc #8160

Closed
wangkuiyi opened this issue Feb 5, 2018 · 0 comments
Closed

Rewrite SimpleUnbufferedChannelTest in channel_test.cc #8160

wangkuiyi opened this issue Feb 5, 2018 · 0 comments
Assignees

Comments

@wangkuiyi
Copy link
Collaborator

The follow unit test has the title SimpleUnbufferedChannelTest

TEST(Channel, SimpleUnbufferedChannelTest) {
auto ch = MakeChannel<int>(0);
unsigned sum_send = 0;
std::thread t([&]() {
for (int i = 0; i < 5; i++) {
EXPECT_EQ(ch->Send(&i), true);
sum_send += i;
}
});
for (int i = 0; i < 5; i++) {
int recv;
EXPECT_EQ(ch->Receive(&recv), true);
EXPECT_EQ(recv, i);
}
CloseChannel(ch);
t.join();
EXPECT_EQ(sum_send, 10U);
delete ch;
}

This implies that it is specifically design to test unbuffered channels.

However, the logic would pass with buffered channels too.

It seems that we should

  1. either rename it to SimpleChannelTest -- remove the word "Unbuffered", or
  2. rewrite it so that it works with unbuffered channel and fails with buffered channels.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants