MCPcopy Create free account
hub / github.com/apache/thrift / test_read_none_available

Function test_read_none_available

lib/cpp/test/TransportTest.cpp:724–749  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

722
723template <class CoupledTransports>
724void test_read_none_available() {
725 CoupledTransports transports;
726 BOOST_REQUIRE(transports.in != nullptr);
727 BOOST_REQUIRE(transports.out != nullptr);
728
729 uint8_t read_buf[16];
730
731 // Attempting to read when no data is available should either block until
732 // some data is available, or fail immediately. (e.g., TSocket blocks,
733 // TMemoryBuffer just fails.)
734 //
735 // If the transport blocks, it should succeed once some data is available,
736 // even if less than the amount requested becomes available.
737 set_trigger(1, transports.out, 2);
738 add_trigger(1, transports.out, 8);
739 uint32_t bytes_read = transports.in->read(read_buf, 10);
740 if (bytes_read == 0) {
741 BOOST_CHECK_EQUAL(g_numTriggersFired, (unsigned int)0);
742 clear_triggers();
743 } else {
744 BOOST_CHECK_EQUAL(g_numTriggersFired, (unsigned int)1);
745 BOOST_CHECK_EQUAL(bytes_read, (uint32_t)2);
746 }
747
748 clear_triggers();
749}
750
751template <class CoupledTransports>
752void test_borrow_none_available() {

Callers

nothing calls this directly

Calls 4

set_triggerFunction · 0.85
add_triggerFunction · 0.85
clear_triggersFunction · 0.85
readMethod · 0.65

Tested by

no test coverage detected