test/psock/test_psock_read_write_raw_uint64.cpp
TEST(read_write)
{
    allocator* alloc = nullptr;
    psock* ls = nullptr;
    psock* rs = nullptr;
    int lhs;
    int rhs;
    const uint64_t EXPECTED_VALUE = 128929839;
    uint64_t val = 0;

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

    /* we should be able to create a socket pair. */
    TEST_ASSERT(
        STATUS_SUCCESS ==
            socket_utility_socketpair(AF_UNIX, SOCK_STREAM, 0, &lhs, &rhs));

    /* we should be able to create a psock from the lhs socket. */
    TEST_ASSERT(
        STATUS_SUCCESS ==
            psock_create_from_descriptor(
                &ls, alloc, lhs));

    /* we should be able to create a psock from the rhs socket. */
    TEST_ASSERT(
        STATUS_SUCCESS ==
            psock_create_from_descriptor(
                &rs, alloc, rhs));

    /* we should be able to write a 64-bit unsigned integer to the lhs sock. */
    TEST_ASSERT(
        STATUS_SUCCESS ==
            psock_write_raw_uint64(ls, EXPECTED_VALUE));

    /* we should be able to read a 64-bit unsigned integer from the rhs sock. */
    TEST_ASSERT(
        STATUS_SUCCESS ==
            psock_read_raw_uint64(rs, &val));

    /* the values should match. */
    TEST_EXPECT(
        EXPECTED_VALUE == val);

    /* clean up. */
    TEST_ASSERT(STATUS_SUCCESS == resource_release(psock_resource_handle(ls)));
    TEST_ASSERT(STATUS_SUCCESS == resource_release(psock_resource_handle(rs)));
    TEST_ASSERT(
        STATUS_SUCCESS == resource_release(allocator_resource_handle(alloc)));
}
/**
 * Verify that we can read and write raw uint64 values.
 */
Verify that we can read and write raw uint64 values.
Verify that we can read and write raw uint64 values .
TEST(read_write)
{
    allocator* alloc = nullptr;
    psock* ls = nullptr;
    psock* rs = nullptr;
    int lhs;
    int rhs;
    const uint64_t EXPECTED_VALUE = 128929839;
    uint64_t val = 0;
    TEST_ASSERT(
        STATUS_SUCCESS == malloc_allocator_create(&alloc));
    TEST_ASSERT(
        STATUS_SUCCESS ==
            socket_utility_socketpair(AF_UNIX, SOCK_STREAM, 0, &lhs, &rhs));
    TEST_ASSERT(
        STATUS_SUCCESS ==
            psock_create_from_descriptor(
                &ls, alloc, lhs));
    TEST_ASSERT(
        STATUS_SUCCESS ==
            psock_create_from_descriptor(
                &rs, alloc, rhs));
    TEST_ASSERT(
        STATUS_SUCCESS ==
            psock_write_raw_uint64(ls, EXPECTED_VALUE));
    TEST_ASSERT(
        STATUS_SUCCESS ==
            psock_read_raw_uint64(rs, &val));
    TEST_EXPECT(
        EXPECTED_VALUE == val);
    TEST_ASSERT(STATUS_SUCCESS == resource_release(psock_resource_handle(ls)));
    TEST_ASSERT(STATUS_SUCCESS == resource_release(psock_resource_handle(rs)));
    TEST_ASSERT(
        STATUS_SUCCESS == resource_release(allocator_resource_handle(alloc)));
}
TEST ( read_write ) { allocator * alloc = nullptr ; psock * ls = nullptr ; psock * rs = nullptr ; int lhs ; int rhs ; const uint64_t EXPECTED_VALUE = 128929839 ; uint64_t val = 0 ; TEST_ASSERT ( STATUS_SUCCESS == malloc_allocator_create ( & alloc ) ) ; TEST_ASSERT ( STATUS_SUCCESS == socket_utility_socketpair ( AF_UNIX , SOCK_STREAM , 0 , & lhs , & rhs ) ) ; TEST_ASSERT ( STATUS_SUCCESS == psock_create_from_descriptor ( & ls , alloc , lhs ) ) ; TEST_ASSERT ( STATUS_SUCCESS == psock_create_from_descriptor ( & rs , alloc , rhs ) ) ; TEST_ASSERT ( STATUS_SUCCESS == psock_write_raw_uint64 ( ls , EXPECTED_VALUE ) ) ; TEST_ASSERT ( STATUS_SUCCESS == psock_read_raw_uint64 ( rs , & val ) ) ; TEST_EXPECT ( EXPECTED_VALUE == val ) ; TEST_ASSERT ( STATUS_SUCCESS == resource_release ( psock_resource_handle ( ls ) ) ) ; TEST_ASSERT ( STATUS_SUCCESS == resource_release ( psock_resource_handle ( rs ) ) ) ; TEST_ASSERT ( STATUS_SUCCESS == resource_release ( allocator_resource_handle ( alloc ) ) ) ; }
Verify that we can read and write raw uint64 values.
Verify that we can read and write raw uint64 values .
/* we should be able to create a malloc allocator. */ /* we should be able to create a socket pair. */ /* we should be able to create a psock from the lhs socket. */ /* we should be able to create a psock from the rhs socket. */ /* we should be able to write a 64-bit unsigned integer to the lhs sock. */ /* we should be able to read a 64-bit unsigned integer from the rhs sock. */ /* the values should match. */ /* clean up. */