test/psock/test_psock_from_buffer_read.cpp
TEST(output_read_fail)
{
    allocator* alloc = nullptr;
    psock* s = nullptr;
    char read_buffer[100];
    size_t read_size;

    /* we should be able to create a malloc allocator. */
    TEST_ASSERT(
        STATUS_SUCCESS == malloc_allocator_create(&alloc));

    /* we should be able to create a psock from the buffer. */
    TEST_ASSERT(
        STATUS_SUCCESS ==
            psock_create_from_buffer(
                &s, alloc, NULL, 0));

    /* read fails. */
    read_size = sizeof(read_buffer);
    TEST_ASSERT(
        ERROR_PSOCK_READ_EOF == psock_read_raw(s, &read_buffer, &read_size));

    /* we should be able to release the socket, which in turn will close the lhs
     * descriptor. */
    TEST_ASSERT(
        STATUS_SUCCESS ==
            resource_release(psock_resource_handle(s)));

    /* clean up. */
    TEST_ASSERT(
        STATUS_SUCCESS == resource_release(allocator_resource_handle(alloc)));
}
/**
 * When the output version of psock_create_from_buffer is used, reads fail.
 */
When the output version of psock_create_from_buffer is used, reads fail.
When the output version of psock_create_from_buffer is used reads fail .
TEST(output_read_fail)
{
    allocator* alloc = nullptr;
    psock* s = nullptr;
    char read_buffer[100];
    size_t read_size;
    TEST_ASSERT(
        STATUS_SUCCESS == malloc_allocator_create(&alloc));
    TEST_ASSERT(
        STATUS_SUCCESS ==
            psock_create_from_buffer(
                &s, alloc, NULL, 0));
    read_size = sizeof(read_buffer);
    TEST_ASSERT(
        ERROR_PSOCK_READ_EOF == psock_read_raw(s, &read_buffer, &read_size));
    TEST_ASSERT(
        STATUS_SUCCESS ==
            resource_release(psock_resource_handle(s)));
    TEST_ASSERT(
        STATUS_SUCCESS == resource_release(allocator_resource_handle(alloc)));
}
TEST ( output_read_fail ) { allocator * alloc = nullptr ; psock * s = nullptr ; char read_buffer [ 100 ] ; size_t read_size ; TEST_ASSERT ( STATUS_SUCCESS == malloc_allocator_create ( & alloc ) ) ; TEST_ASSERT ( STATUS_SUCCESS == psock_create_from_buffer ( & s , alloc , NULL , 0 ) ) ; read_size = sizeof ( read_buffer ) ; TEST_ASSERT ( ERROR_PSOCK_READ_EOF == psock_read_raw ( s , & read_buffer , & read_size ) ) ; TEST_ASSERT ( STATUS_SUCCESS == resource_release ( psock_resource_handle ( s ) ) ) ; TEST_ASSERT ( STATUS_SUCCESS == resource_release ( allocator_resource_handle ( alloc ) ) ) ; }
When the output version of psock_create_from_buffer is used, reads fail.
When the output version of psock_create_from_buffer is used reads fail .
/* we should be able to create a malloc allocator. */ /* we should be able to create a psock from the buffer. */ /* read fails. */ /* we should be able to release the socket, which in turn will close the lhs
     * descriptor. */ /* clean up. */