test/message/test_message_create.cpp
TEST(create)
{
    allocator* alloc = nullptr;
    message* msg = nullptr;
    allocator* payload_allocator = nullptr;
    resource* payload = nullptr;
    mailbox_address returnaddr = 907;

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

    /* we should be able to create a dummy allocator for our payload. */
    TEST_ASSERT(
        STATUS_SUCCESS == malloc_allocator_create(&payload_allocator));

    /* convert the payload allocator to a resource. */
    payload = allocator_resource_handle(payload_allocator);

    /* we should be able to create a message. */
    TEST_ASSERT(
        STATUS_SUCCESS == message_create(&msg, alloc, returnaddr, payload));

    /* the return address matches. */
    TEST_EXPECT(
        returnaddr == message_return_address(msg));

    /* the payload matches. */
    TEST_EXPECT(
        payload == message_payload(msg, false));

    /* clean up. */
    TEST_ASSERT(
        STATUS_SUCCESS == resource_release(message_resource_handle(msg)));
    TEST_ASSERT(
        STATUS_SUCCESS == resource_release(allocator_resource_handle(alloc)));
}
/**
 * Verify that we can create and release a message instance.
 */
Verify that we can create and release a message instance.
Verify that we can create and release a message instance .
TEST(create)
{
    allocator* alloc = nullptr;
    message* msg = nullptr;
    allocator* payload_allocator = nullptr;
    resource* payload = nullptr;
    mailbox_address returnaddr = 907;
    TEST_ASSERT(
        STATUS_SUCCESS == malloc_allocator_create(&alloc));
    TEST_ASSERT(
        STATUS_SUCCESS == malloc_allocator_create(&payload_allocator));
    payload = allocator_resource_handle(payload_allocator);
    TEST_ASSERT(
        STATUS_SUCCESS == message_create(&msg, alloc, returnaddr, payload));
    TEST_EXPECT(
        returnaddr == message_return_address(msg));
    TEST_EXPECT(
        payload == message_payload(msg, false));
    TEST_ASSERT(
        STATUS_SUCCESS == resource_release(message_resource_handle(msg)));
    TEST_ASSERT(
        STATUS_SUCCESS == resource_release(allocator_resource_handle(alloc)));
}
TEST ( create ) { allocator * alloc = nullptr ; message * msg = nullptr ; allocator * payload_allocator = nullptr ; resource * payload = nullptr ; mailbox_address returnaddr = 907 ; TEST_ASSERT ( STATUS_SUCCESS == malloc_allocator_create ( & alloc ) ) ; TEST_ASSERT ( STATUS_SUCCESS == malloc_allocator_create ( & payload_allocator ) ) ; payload = allocator_resource_handle ( payload_allocator ) ; TEST_ASSERT ( STATUS_SUCCESS == message_create ( & msg , alloc , returnaddr , payload ) ) ; TEST_EXPECT ( returnaddr == message_return_address ( msg ) ) ; TEST_EXPECT ( payload == message_payload ( msg , false ) ) ; TEST_ASSERT ( STATUS_SUCCESS == resource_release ( message_resource_handle ( msg ) ) ) ; TEST_ASSERT ( STATUS_SUCCESS == resource_release ( allocator_resource_handle ( alloc ) ) ) ; }
Verify that we can create and release a message instance.
Verify that we can create and release a message instance .
/* we should be able to create a malloc allocator. */ /* we should be able to create a dummy allocator for our payload. */ /* convert the payload allocator to a resource. */ /* we should be able to create a message. */ /* the return address matches. */ /* the payload matches. */ /* clean up. */