| 7 | |
| 8 | Y_UNIT_TEST_SUITE(TSocketPollerTest) { |
| 9 | Y_UNIT_TEST(TestSimple) { |
| 10 | SOCKET sockets[2]; |
| 11 | UNIT_ASSERT(SocketPair(sockets) == 0); |
| 12 | |
| 13 | TSocketHolder s1(sockets[0]); |
| 14 | TSocketHolder s2(sockets[1]); |
| 15 | |
| 16 | TSocketPoller poller; |
| 17 | poller.WaitRead(sockets[1], (void*)17); |
| 18 | |
| 19 | UNIT_ASSERT_VALUES_EQUAL(nullptr, poller.WaitT(TDuration::Zero())); |
| 20 | UNIT_ASSERT_VALUES_EQUAL(nullptr, poller.WaitT(TDuration::Zero())); |
| 21 | |
| 22 | for (ui32 i = 0; i < 3; ++i) { |
| 23 | char buf[] = {18}; |
| 24 | UNIT_ASSERT_VALUES_EQUAL(1, send(sockets[0], buf, 1, 0)); |
| 25 | |
| 26 | UNIT_ASSERT_VALUES_EQUAL((void*)17, poller.WaitT(TDuration::Zero())); |
| 27 | |
| 28 | UNIT_ASSERT_VALUES_EQUAL(1, recv(sockets[1], buf, 1, 0)); |
| 29 | UNIT_ASSERT_VALUES_EQUAL(18, buf[0]); |
| 30 | |
| 31 | UNIT_ASSERT_VALUES_EQUAL(nullptr, poller.WaitT(TDuration::Zero())); |
| 32 | UNIT_ASSERT_VALUES_EQUAL(nullptr, poller.WaitT(TDuration::Zero())); |
| 33 | } |
| 34 | } |
| 35 | |
| 36 | Y_UNIT_TEST(TestSimpleOneShot) { |
| 37 | SOCKET sockets[2]; |
nothing calls this directly
no test coverage detected